This is intended as an extension of the original question, The number of the current paragraph? How can I get it?, which does a nice job answering the question for iWork Pages. http://macscripter.net/viewtopic.php?id=29125
I would like to do the same thing in Microsoft Word.
My ultimate goal is to run a loop over the document that finds all tables and inserts a section break continuous before and after it.
The following VBA Script provides a pop-up dialog which shows the data I need and more (paragraph, absolute line number, relative line number). Maybe someone can help me set the output of this script to a document variable that I can access via AppleScript with
get variable value of variable "paragraphNum" of active document
Here is the VBA Script:
When I get the paragraph number, I can then insert a section break continuous before by doing something similar to this (of course I would need to do select the last character of the preceding paragraph and the first character of the subsequent paragraph, but I need to get the paragraph number of the table first!):
insert break at text object of selection break type section break continuous
Model: Macbook Air 2011
AppleScript: 2.5.1 (138.1)
Browser: Firefox 20.0
Operating System: Mac OS X (10.8)
tell application "Microsoft Word"
set myDoc to active document
set myRange to create range myDoc start 0 end (start of content of text object of selection)
set paragraphNum to (count paragraphs in myRange)
end tell
Or as a handler
GetParagraph()
on GetParagraph()
tell application "Microsoft Word"
set myDoc to active document
set myRange to create range myDoc start 0 end (start of content of text object of selection)
set paragraphNum to (count paragraphs in myRange)
return paragraphNum
end tell
end GetParagraph