|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How can I expand the range of an endnote with multiple paragraphs in the text?
I am working on my first VBA script which needs to copy the reference text of each endnote. I'm able to set a range for the endnote reference text fine except when the writer's have added multiple paragraphs. I am currently expanding my range to the end of the paragraph, however it only expands the end of the range to the first paragraph. Is it possible to expand the range to multiple paragraphs? Here's my code for getting the range now:
Code:
rng_source.Expand Unit:=wdParagraph Here's an example of a typical endnote. The # represents where the endnote superScript would be. Notice the writers put text (ABC) before the endnote number: (ABC) #Some text paragraph1 Possible additional text paragraph2 paragraph3, etc. (XYZ) #Next endnote. Could have only 1 or more paragraphs. |
#2
|
||||
|
||||
You can move the start or end of a range in a forward or backward direction
Code:
rng_Source.MoveEnd Unit:=wdParagraph, Count:=2 rng_Source.MoveEnd Unit:=wdParagraph, Count:=-2 rng_Source.MoveStart Unit:=wdCharacter, Count:=-10 rng_Source.MoveStart Unit:=wdWord, Count:=5
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
||||
|
||||
You seem to be making this overly complicated:
Code:
Sub Demo() Application.ScreenUpdating = False Dim eNt As Endnote With ActiveDocument For Each eNt In .Endnotes MsgBox "EndNote:" & vbCr & eNt.Index & vbCr & "Text:" & vbCr & eNt.Range.Text Next End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
Thanks for the help, Macropod. Your code helped get me on the right track.
|
Tags |
endnote reference, range |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can I select all the text in a table cell when it contains multiple paragraphs? | wrdy | Word | 4 | 05-18-2022 12:25 AM |
Loop to Collapse Paragraphs within Range Not Working | poetofpiano | Word VBA | 1 | 03-11-2018 06:29 PM |
Endnote and in-text citations in Word | nato2015 | Word | 1 | 07-04-2015 03:35 PM |
endnote and import reference from word to endnote | uncung | Word | 0 | 06-18-2011 08:09 AM |
Cross-reference endnote text | smed | Word | 3 | 01-14-2011 03:34 PM |