PDA

View Full Version : Trouble positioning image in header



babsiee
12-17-2013, 01:37 AM
I am sorry for double posting but I couldn't open the thread I've posted. Here it goes again, this time with the VBA code I am using. Hope someone will be able to help me :)

Hi guys,
I am setting up a simple macro.
It's structures like this:

- first page header
inserts image 1

- first page footer
inserts image 2

- page header
inserts image 1

- page footer
inserts image 3

Since I'm not an expert in VBA it works out fine but is nothing special.
The image is uploaded on the internet so I can use the macro at different computers without having to have the image.
Now I have a specific wish and I do not know how to do this. Here it goes:

I would like to have my first and second header image to be in the top right corner ánd to be behind the text of the letter I will be typing. How do I do this?

Any tips or advice where to look would be highly appreciated.
Thanks!


Sub AAANieuw()

'


' AAANieuw Macro


'
' Custom form page parameters
Const FPageWid = 7: Const FPageHgt = 2#
Const FMargLft = 1: Const FMargRgt = 0.78
Const FMargTop = 1.77: Const FMargBot = 0.78


' Word page dimensions
Const WPageWid = 8.5: Const WPageHgt = 11


' Printer no-print area
Const PNoPrTop = 0.25: Const PNoPrBot = 0.25
Const PNoPrLft = 0.25: Const PNoPrRgt = 0.25


Dim WMargTop, WMargBot, WMargLft, WMargRgt ' Word margins
WMargTop = FMargTop
WMargBot = FMargBot
WMargLft = FMargLft
WMargRgt = FMargRgt


Dim oDoc As Document
Dim oVars As Variables
Set oDoc = ActiveDocument
Set oVars = oDoc.Variables


With oVars
.Add("WMargTop").Value = WMargTop
.Add("WMargBot").Value = WMargBot
.Add("WMargLft").Value = WMargLft
.Add("WMargRgt").Value = WMargRgt
End With


With oDoc.PageSetup
.TopMargin = InchesToPoints(oVars("WMargTop").Value)
.BottomMargin = InchesToPoints(oVars("WMargBot").Value)
.LeftMargin = InchesToPoints(oVars("WMargLft").Value)
.RightMargin = InchesToPoints(oVars("WMargRgt").Value)
End With



ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader 'HEADER PAGINA 2 en verder
With Dialogs(wdDialogInsertPicture)
.Name = "http://www.babettezijlstra.nl/wp-content/uploads/Header-Een-BCA.jpg"
.Execute
End With


ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter 'FOOTER PAGINA 2 en verder
Selection.TypeText Text:="alle opdrachten worden aanvaard en uitgevoerd overeenkomstig onze algemene voorwaarden gedeponeerd bij de k.v.k. Rotterdam 24338874"
Selection.MoveLeft Unit:=wdCharacter, Count:=192, Extend:=wdExtend
Selection.Font.Name = "Arial"
Selection.Font.Size = 7
ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True


Dim asection As Section


Set asection = Selection.Sections(1)


With asection


With .PageSetup


End With


ActiveWindow.ActivePane.View.SeekView = wdHeaderFooterFirstPage 'HEADER PAGINA 1
With Dialogs(wdDialogInsertPicture)
.Name = "http://www.babettezijlstra.nl/wp-content/uploads/Header-Een-BCA.jpg"
.FloatOverText = False
.Execute
End With


'footer pagina 1
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter

With Dialogs(wdDialogInsertPicture)
.Name = "http://www.babettezijlstra.nl/wp-content/uploads/Footer-Een.jpg"
.FloatOverText = False
.Execute
End With




ActiveWindow.ActivePane.View.Type = wdPageView

End With
End Sub

macropod
12-19-2013, 08:39 PM
Hi babsiee,

Why are you doing all this in code instead of using a template with all of the required content & parameters already in place?