Insert autotext on last paragraph of each page

S

Steved

Hello from Steved

I would like to find the last paragraph on a page and then insert
an autotext by using the word "Win" please. if posible can it be looped as
sometimes I have only 10 pages or I might have up to 30 pages.

Thankyou.
 
S

Steved

Hello from Steved

My attempt is that it will not insert the autotext

Sub test()
ActiveDocument.Bookmarks("\Page").Range.Characters.Last.Select
'Move to start of the line
Selection.HomeKey wdLine
ActiveDocument.AttachedTemplate.AutoTextEntries("Win").Insert

End Sub
 
G

Greg Maxey

Not very elegant but seems to work:

Sub ScracthMacro()
Dim oRng As Word.Range
Dim i As Long
Dim j As Long
Dim count As Long
count = ActiveDocument.ComputeStatistics(wdStatisticPages)
Set oRng = ActiveDocument.Range
oRng.Collapse wdCollapseStart
oRng.Select
For j = 1 To count
i = Selection.Bookmarks("\Page").Range.Paragraphs.Last.Range.Start
oRng.Start = i
oRng.Select
ActiveDocument.AttachedTemplate.AutoTextEntries("Win").Insert
Selection.Range
Selection.MoveDown wdParagraph, 1
Set oRng = Selection.Range
Next j
End Sub
 

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