carsRST
asked on
Word VBA - read a specific line number
With VBA, I'm trying to read a specific line number in a Word document. See code snippet below.
What do i need to include to read a specific line number? For example, how do I change the code to read from line 11 in the Word document and store to variable "strText"
Also need to be able to specify a particular page. So page 2, line 11.
What do i need to include to read a specific line number? For example, how do I change the code to read from line 11 in the Word document and store to variable "strText"
Also need to be able to specify a particular page. So page 2, line 11.
Set doc = wrd.Application.Documents.Open(strFilePath)
strText = '......code to read all of line 11'
doc.Close
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
strText = doc.Paragraphs(11).Range.T
There is no text line object in Word, because what is displayed on a line depends on so many things - printer, font, etc.
However, this function should return the text for the current environment
Open in new window