L
Liz130
In Word 2003 I had a lovely macro that I used to place the filename, author,
creation date, revision date, and page number into a footer that repeated on
every page. I would open a blank file, save it to the filename I wanted it
to have, run my macro and poof the footer was exactly as I wanted. I cannot
make Word 2007 do that for me. The macro blows up with Run-time error '5941':
The requested member of the collection does not exist.
I created the macro using the record device in macro. Debug highlights the
two lines " ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain
Number 2"). _
Insert Where:=Selection.Range, RichText:=True"
Here is the full code:
Sub Foot()
'
' Foot Macro
' Create Footer for Manuscripts
'
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain Number 2"). _
Insert Where:=Selection.Range, RichText:=True
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"FILENAME ", PreserveFormatting:=True
Selection.TypeText Text:=" "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"AUTHOR ", PreserveFormatting:=True
Selection.TypeText Text:=" "
Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _
False, DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.TypeText Text:=" "
Selection.InsertDateTime DateTimeFormat:="M/d/yyyy h:mm am/pm", _
InsertAsField:=True, DateLanguage:=wdEnglishUS, CalendarType:= _
wdCalendarWestern, InsertAsFullWidth:=False
Selection.TypeText Text:=" "
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
creation date, revision date, and page number into a footer that repeated on
every page. I would open a blank file, save it to the filename I wanted it
to have, run my macro and poof the footer was exactly as I wanted. I cannot
make Word 2007 do that for me. The macro blows up with Run-time error '5941':
The requested member of the collection does not exist.
I created the macro using the record device in macro. Debug highlights the
two lines " ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain
Number 2"). _
Insert Where:=Selection.Range, RichText:=True"
Here is the full code:
Sub Foot()
'
' Foot Macro
' Create Footer for Manuscripts
'
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain Number 2"). _
Insert Where:=Selection.Range, RichText:=True
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"FILENAME ", PreserveFormatting:=True
Selection.TypeText Text:=" "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"AUTHOR ", PreserveFormatting:=True
Selection.TypeText Text:=" "
Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _
False, DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.TypeText Text:=" "
Selection.InsertDateTime DateTimeFormat:="M/d/yyyy h:mm am/pm", _
InsertAsField:=True, DateLanguage:=wdEnglishUS, CalendarType:= _
wdCalendarWestern, InsertAsFullWidth:=False
Selection.TypeText Text:=" "
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub