PDA

View Full Version : Insert text into footer after page number



gav12345
07-10-2012, 02:12 AM
Hi all,

For clarity, this is related to the 'Add text to footer' thread I recently raised, but I thought this sub-issue might benefit from a new thread.

What we are trying to do is insert a textual ID string in a report footer, depending on what is already in the footer.

There are a few conditions to the code, but for this particular part if there is any existing text in the footer then the code should insert a carriage return after the text, and then insert the ID number after that.

Problem is, the code I currently have does not recognise page numbers as text, so if there is only a page number and nothing else in the footer, the ID is not inserted correctly.

Can anyone tell me how I can identify a page number in the page footer, and insert a text string after it? Our current code is:

With .Find
.Text = "?"
.MatchWildcards = True
.Execute
End With
If .Find.Found Then
'Insert the ID after the last character in the footer section
Scn.Footers(wdHeaderFooterFirstPage).Range.Characters.Last.InsertAfter vbCrLf & "TM Doc ID: " & idStr

Thanks for any suggestions, Gavin

macropod
07-10-2012, 03:38 AM
See my reply to your other thread.