View Single Post
 
Old 09-14-2016, 06:42 AM
youseeme youseeme is offline Windows 10 Office 2013
Novice
 
Join Date: Sep 2016
Posts: 6
youseeme is on a distinguished road
Default Macro to Insert Logo in header on 1st page only and bookmark it.

Hi,

Looking for some help please... I'm trying to create a word macro which will insert a logo and address details into the 1st page header & bookmark them.
I can't use a template as we generate word documents from a DMS.

So far from using macro examples found on the internet I have...
Sub AddLogo()
Application.ScreenUpdating = False
ActiveDocument.PageSetup.DifferentFirstPageHeaderF ooter = True
Dim sh As Shape
Dim hdr As HeaderFooter
Dim rng As Range
Dim strPicture As String

strPicture = "Z:\Logo1.jpg"
For Each hdr In ActiveDocument.Sections(1).Headers
Set rng = hdr.Range
rng.Collapse wdCollapseEnd
Set sh = ActiveDocument.Shapes.AddPicture(strPicture, False, True, 0, 0, , , rng)
With sh
.Height = CentimetersToPoints(4.94)
.Width = CentimetersToPoints(3.58)
.LockAspectRatio = True
.Left = CentimetersToPoints(13.67)
.Top = CentimetersToPoints(-1.23)
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapNone
End With
Next hdr

strPicture = "Z:\Logo2.jpg"
For Each hdr In ActiveDocument.Sections(1).Headers
Set rng = hdr.Range
rng.Collapse wdCollapseEnd
Set sh = ActiveDocument.Shapes.AddPicture(strPicture, False, True, 0, 0, , , rng)
With sh
.Height = CentimetersToPoints(4.29)
.Width = CentimetersToPoints(4.84)
.LockAspectRatio = True
.Left = CentimetersToPoints(7.83)
.Top = CentimetersToPoints(-0.27)
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapNone
End With
Next hdr
End Sub

This adds a couple of logos into the header but for every page rather than the first page. I'm also not sure how to bookmark the image being added so I can hide it later on in a separate print macro.

Thanks for any help.
Reply With Quote