determine current line number

M

Marco

I am trying to determine the current line number in a long document. I tried
using Selection.Information(wdFirstCharacterLineNumber) but this returns the
line number relative to the page the selection is in. I want the line number
relative to the beginning of the file. Thanks!
 
D

Doug Robbins - Word MVP

Pages are a bit of an abstract term in Word. What do you want to do with
the line number if you could get it?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

Marco

I want to import a text file generated by a Unix application into Excel, but
first I clean up the file in Word because data is not aligned in columns,
there are page headers mixed with data, etc. As a final step I want to
truncate the last part of the file and save it back in .TXT format.
Since the text files will vary in size, it would be helpful to determine the
line number from which to start deleting. When I manipulate the text file in
Word, the number of lines on a page varies according to font size, style,
page orientation, etc.

I hope I was clear, Doug. Thank you very much for your attention.
 
D

Doug Robbins - Word MVP

Assuming from your original post that the Selection is in the first of the
lines that you want to delete, use

Dim delrange as Range
Set delrange = ActiveDocument.Range
delrange.Start=Selection.Paragraphs(1).Range.Start
delrange.Delete

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

Marco

After finding the starting point to delete, I used Selection.MoveEnd
Unit:=wdStory, Count:=1 ; I really did not need the line number.

Just out of curiosity, is it possible to retrieve the line number? There is
a GoTo method that lets you pick a line number to jump to, something like

Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=25

Thank you, Doug.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top