|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How to write a macro to count the number of lines between the start of a Word document to where the
I want to write a macro to count the number of lines between the start of a Word document to where the cursor lies?
Is it possible? If so, can you give me some ideas about how this code should be written? |
#2
|
||||
|
||||
Lines or Paragraphs?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
@Andrew Lockton: Lines
|
#4
|
||||
|
||||
Lines is not the answer I wanted to hear. The concept of lines is particularly problematic as Word has no fixed way of handling it.
For instance, how many lines in a table containing multiple columns? How many lines in a graphic? Do we count empty paragraphs, hard page breaks, section breaks etc.? One feature you might want to consider is turning on Layout > Line Numbers. This will show you that tables are excluded from the numbering. On any given page this should return the line number on the page - unfortunately it returns odd results when tables appear before it. It seems to include some but not all cells. Selection.Range.Information(wdFirstCharacterLineNu mber) As far as I can tell, you would then need to iterate through all preceding pages to work out how many lines on each page and add them all together.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
Tags |
lines of text, macro |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Delete lines with just a number on them - use macro or find & replace? | enso | Word | 2 | 05-20-2019 02:58 AM |
Looking for a macro to increase a number by 1 in a Word document | Olopocram | Word VBA | 15 | 03-07-2018 05:39 PM |
Count Number of Pages in Document with Footnotes | d4okeefe | Word VBA | 5 | 11-11-2013 11:02 AM |
'Start At' number changes when document is reopened after saving | cattail722 | Word | 5 | 08-26-2013 10:51 AM |
How do I number the lines in a document? | NepalKat | Word | 3 | 07-13-2011 06:09 AM |