PDA

View Full Version : Autotext Update Code to include 2007 Building Blocks please?



Janine
08-31-2007, 01:30 AM
I get an error on "Insert last.... Autotext " How do I make it work for 2007 Building Blocks as well please?:cloud9: Option Explicit

Sub PathInFooter()
Dim oRange As Word.Range

'Get a handle to the firstpage Footer
Set oRange = ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range

'Get autotext from Normal.dot
With NormalTemplate
'Insert Filename and path in footer
.AutoTextEntries("Filename and path").Insert Where:=oRange, RichText:=True

With oRange
'Insert paragraph mark after the filename
.InsertAfter Text:=vbCr

'Collapse to the end of the range
.Collapse Direction:=wdCollapseEnd
End With

'Insert Last saved by {Name} in footer
.AutoTextEntries("Last saved by").Insert Where:=oRange, RichText:=True
End With

'Clean up
Set oRange = Nothing
End Sub

fumei
09-04-2007, 12:46 PM
When you mention errors, it is helpful to actually state what the error is. We may be able to get a clue from knowing that.

The code above runs fine with Word 2002, so I have no idea what may be wrong with it in 2007. Depending on what the actual error says, it may be something to do with collapsing the range to a point. Just guessing here.