- Joined
- May 6, 2014
- Messages
- 2
- Reaction score
- 0
Hi all,
I have created a macro in Word 2010 to input an image as a header and footer. The only thing is, the header image needs to be 1cm (in A4 paper terms) from the top of the page. Yet it is slightly lower. In the macro I have written Selection.ShapeRange.Top = PixelsToPoints(0). Although this is set to 0 it still hasn't made the image higher. I would appreciate it if I could get help on how to do this.
Sub BucklesTemplate()
'
' BucklesTemplate Macro
' Macro coded 01/04/2014 by Rajan Kandola
'
'switch to header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
'add logo to header
With ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, _
FileName:="C:\Users\kandolar.BUCKLEMELLOWS\Desktop\Buckles Letter Format\logo.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
.WrapFormat.Type = 3
.ZOrder 4
.LockAspectRatio = False
End With
'select the last item in shapes list - should be logo that was just added
Selection.HeaderFooter.Shapes(Selection.HeaderFooter.Shapes.Count).Select
'set relative vertical position to Page So that it will stay in the header
Selection.ShapeRange.Top = PixelsToPoints(0)
'reposition the logo - to test I moved them horizontally to about the center of the page
Selection.ShapeRange.Left = PixelsToPoints(210)
'switch to footer
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
'add banner to footer
With ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, _
FileName:="C:\Users\kandolar.BUCKLEMELLOWS\Desktop\Buckles Letter Format\disclaimer+btmBanner.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
.WrapFormat.Type = 3
.ZOrder 4
.LockAspectRatio = False
'change size of footer image
.Height = InchesToPoints(1.3)
.Width = InchesToPoints(8.31)
'make footer image relative to margin
.WrapFormat.Type = wdRelativeVerticalPositionMargin
End With
'select the last item in shapes list - should be logo that was just added
Selection.HeaderFooter.Shapes(Selection.HeaderFooter.Shapes.Count).Select
'set relative vertical position to Page So that it will stay in the footer
Selection.ShapeRange.Top = PixelsToPoints(980)
'reposition the logo - to test I moved them horizontally to about the center of the page
Selection.ShapeRange.Left = PixelsToPoints(0)
'switch back to main document
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
Many thanks,
Rajan
I have created a macro in Word 2010 to input an image as a header and footer. The only thing is, the header image needs to be 1cm (in A4 paper terms) from the top of the page. Yet it is slightly lower. In the macro I have written Selection.ShapeRange.Top = PixelsToPoints(0). Although this is set to 0 it still hasn't made the image higher. I would appreciate it if I could get help on how to do this.
Sub BucklesTemplate()
'
' BucklesTemplate Macro
' Macro coded 01/04/2014 by Rajan Kandola
'
'switch to header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
'add logo to header
With ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, _
FileName:="C:\Users\kandolar.BUCKLEMELLOWS\Desktop\Buckles Letter Format\logo.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
.WrapFormat.Type = 3
.ZOrder 4
.LockAspectRatio = False
End With
'select the last item in shapes list - should be logo that was just added
Selection.HeaderFooter.Shapes(Selection.HeaderFooter.Shapes.Count).Select
'set relative vertical position to Page So that it will stay in the header
Selection.ShapeRange.Top = PixelsToPoints(0)
'reposition the logo - to test I moved them horizontally to about the center of the page
Selection.ShapeRange.Left = PixelsToPoints(210)
'switch to footer
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
'add banner to footer
With ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, _
FileName:="C:\Users\kandolar.BUCKLEMELLOWS\Desktop\Buckles Letter Format\disclaimer+btmBanner.jpg", _
LinkToFile:=False, SaveWithDocument:=True)
.WrapFormat.Type = 3
.ZOrder 4
.LockAspectRatio = False
'change size of footer image
.Height = InchesToPoints(1.3)
.Width = InchesToPoints(8.31)
'make footer image relative to margin
.WrapFormat.Type = wdRelativeVerticalPositionMargin
End With
'select the last item in shapes list - should be logo that was just added
Selection.HeaderFooter.Shapes(Selection.HeaderFooter.Shapes.Count).Select
'set relative vertical position to Page So that it will stay in the footer
Selection.ShapeRange.Top = PixelsToPoints(980)
'reposition the logo - to test I moved them horizontally to about the center of the page
Selection.ShapeRange.Left = PixelsToPoints(0)
'switch back to main document
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
Many thanks,
Rajan