clhare
11-19-2010, 07:27 AM
I need to switch a logo in the first page footer to another logo. I have bookmarked the logo and created an AutoText entry for the replacement logo. I created a simple macro for this by recording my steps (all I added was the comments). When I recorded this macro, it worked great. When I run it, it says it can't find the bookmark.
How do I get this macro to work? I can't just replace the entire footer as it also contains 2 lines of text that needs to stay.
Sub SwitchToBlackLogoInFooter()
' Go to start of document to get to title page
Selection.HomeKey Unit:=wdStory
' Go to footer
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
' Go to logo bookmark
Selection.GoTo What:=wdGoToBookmark, Name:="FooterLogo"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
' Delete logo
Selection.ShapeRange.Delete
' Insert AutoText entry for new logo
NormalTemplate.AutoTextEntries("FooterLogo_Black").Insert Where:=Selection _
.Range, RichText:=True
' Return to main document
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
How do I get this macro to work? I can't just replace the entire footer as it also contains 2 lines of text that needs to stay.
Sub SwitchToBlackLogoInFooter()
' Go to start of document to get to title page
Selection.HomeKey Unit:=wdStory
' Go to footer
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
' Go to logo bookmark
Selection.GoTo What:=wdGoToBookmark, Name:="FooterLogo"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
' Delete logo
Selection.ShapeRange.Delete
' Insert AutoText entry for new logo
NormalTemplate.AutoTextEntries("FooterLogo_Black").Insert Where:=Selection _
.Range, RichText:=True
' Return to main document
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub