I've been trying to replace the title image on a large number of word documents using a recorded macro and replace the footer image. However, when I run the macro on a new document, it doesn't replace the images and deletes the text from the text box. It doesn't touch the footer image at all. I've used basic recorded macros in the past but not to replace images or images in the footer. A friend mentioned that VBA might be needed to insert the image, but I'm less than a novice in that language.
Sub BrandingUpdateV2()
'
' BrandingUpdateV2 Macro
'
'
ActiveDocument.Shapes.Range(Array("Text Box 2")).Select
Selection.TypeBackspace
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.MoveDown Unit:=wdLine, Count:=13
Selection.MoveUp Unit:=wdLine, Count:=3
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 = wdSeekCurrentPageFooter
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.MoveDown Unit:=wdLine, Count:=42
Selection.MoveUp Unit:=wdLine, Count:=10
Selection.MoveDown Unit:=wdLine, Count:=1
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 = wdSeekCurrentPageFooter
Selection.HeaderFooter.Shapes.Range(Array("Group 50")).Select
Selection.HeaderFooter.Shapes.Range(Array("Slide Number Placeholder 11" _
)).Select
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
ActiveDocument.sections(1).Headers(wdHeaderFooterPrimary)
to turn some up. – Cindy MeisterShapes
) - but I can tell you that replacing aShape
is not a simple matter. It involves deleting the current one, inserting a new one and re-applying all the properties (position, size, etc.) There is no equivalent to the UI "Change picture" command in VBA. – Cindy Meister