Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-07-2021, 08:14 PM
soroush.kalantari soroush.kalantari is offline How to write a macro to count the number of lines between the start of a Word document to where the Windows 10 How to write a macro to count the number of lines between the start of a Word document to where the Office 2016
Competent Performer
How to write a macro to count the number of lines between the start of a Word document to where the
 
Join Date: Jun 2021
Posts: 115
soroush.kalantari is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 08-08-2021, 04:07 PM
Guessed's Avatar
Guessed Guessed is offline How to write a macro to count the number of lines between the start of a Word document to where the Windows 10 How to write a macro to count the number of lines between the start of a Word document to where the Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Lines or Paragraphs?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-08-2021, 07:40 PM
soroush.kalantari soroush.kalantari is offline How to write a macro to count the number of lines between the start of a Word document to where the Windows 10 How to write a macro to count the number of lines between the start of a Word document to where the Office 2016
Competent Performer
How to write a macro to count the number of lines between the start of a Word document to where the
 
Join Date: Jun 2021
Posts: 115
soroush.kalantari is on a distinguished road
Default

@Andrew Lockton: Lines
Reply With Quote
  #4  
Old 08-08-2021, 09:23 PM
Guessed's Avatar
Guessed Guessed is offline How to write a macro to count the number of lines between the start of a Word document to where the Windows 10 How to write a macro to count the number of lines between the start of a Word document to where the Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
Reply

Tags
lines of text, macro

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write a macro to count the number of lines between the start of a Word document to where the Delete lines with just a number on them - use macro or find & replace? enso Word 2 05-20-2019 02:58 AM
How to write a macro to count the number of lines between the start of a Word document to where the Looking for a macro to increase a number by 1 in a Word document Olopocram Word VBA 15 03-07-2018 05:39 PM
How to write a macro to count the number of lines between the start of a Word document to where the Count Number of Pages in Document with Footnotes d4okeefe Word VBA 5 11-11-2013 11:02 AM
How to write a macro to count the number of lines between the start of a Word document to where the 'Start At' number changes when document is reopened after saving cattail722 Word 5 08-26-2013 10:51 AM
How to write a macro to count the number of lines between the start of a Word document to where the How do I number the lines in a document? NepalKat Word 3 07-13-2011 06:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft