Creating Word Header - insert and position picture (1 Viewer)

mdnuts

Registered User.
Local time
Today, 04:25
Joined
May 28, 2014
Messages
128
Hello,

Having trouble getting access vba to set a word document's header properly. I've got this.
Code:
oDoc.PageSetup.DifferentFirstPageHeaderFooter = True  
oDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Range.InlineShapes.AddPicture "C:\Users\mr.helpless\Pictures\doody.jpg"
oDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Range.Text = "hello there"
oDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "whooo hooo!"
What happens right now is the text will replace the picture for the first page (subsequent pages are fine).

I need to have the picture and text - and I need to offset the picture to the left about half an inch while text is centered with normal margins.

**Update**
I got half of it done, now I just need to alter the position of the image.

Code:
        Dim myText As String
        myText = "hello there"

        With oDoc.Sections(1).Headers(wdHeaderFooterFirstPage)
          .Shapes.AddPicture Filename:="C:\Users\mr.helpless\Pictures\doody.jpg", LinkToFile:=False, SaveWithDocument:=True
          .Range.Collapse
          .Range.InsertAfter (myText)
          .Range.Font.Name = "Helvetica"
          .Range.Font.Size = 8
          .Range.Font.Bold = True
          .Range.Paragraphs.Alignment = wdAlignParagraphCenter
        End With
 
Last edited:

mdnuts

Registered User.
Local time
Today, 04:25
Joined
May 28, 2014
Messages
128
And nevermind - I got it.

After "SaveWithDocument:=True i just needed to add: "Left:=-30,"

Or whatever value works.
 

Users who are viewing this thread

Top Bottom