WORD VBA macro for Picture Size and Position

N

Nano A.

Hello Guys,

I have several Docs that I have to insert several images in the Header section as a background.

These images are the same size as the word page (US Letter), but when I import them they appear reduced, so I thought of making a Macro to automatically resize them to 100% (US Letter = 215.9 x 279.4) and reposition to 0,0 relative to the page (meaning the top left corner of the page)

Does anyone know how can I program a macro to do this?

I tried recording a Macro but when I use position it crashes.

I already changed the preferences in word to insert the images in front of text so they are not inline when I import them.

Thanks!

Nano
 
H

Harold Druss

Nano A. said:
Hello Guys,

I have several Docs that I have to insert several images in the Header
section as a background.

These images are the same size as the word page (US Letter), but when I
import them they appear reduced, so I thought of making a Macro to
automatically resize them to 100% (US Letter = 215.9 x 279.4) and
reposition to 0,0 relative to the page (meaning the top left corner of the
page)

Does anyone know how can I program a macro to do this?

I tried recording a Macro but when I use position it crashes.

I already changed the preferences in word to insert the images in front of
text so they are not inline when I import them.

Thanks!

Nano
Hi Nano
I used Word 2003 and recorded this macro that worked fine.
===============================================================
Sub Macro5()
'
' Macro5 Macro
' Macro recorded 10/22/2011 by H. Druss
'
ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddPicture(FileName:= _
"C:\Documents and Settings\Compaq_Owner\Desktop\picture for
background.jpg" _
, LinkToFile:=False, SaveWithDocument:=True).Select
Selection.ShapeRange.Name = "WordPictureWatermark1"
Selection.ShapeRange.PictureFormat.Brightness = 0.85
Selection.ShapeRange.PictureFormat.Contrast = 0.15
Selection.ShapeRange.LockAspectRatio = True
Selection.ShapeRange.Height = InchesToPoints(11)
Selection.ShapeRange.Width = InchesToPoints(8.5)
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapNone
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.Left = wdShapeCenter
Selection.ShapeRange.Top = wdShapeCenter
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
===============================================================

The macro was recorded using?
Format
Background
Printed Watermark
Picture Watermark
Scale 100%

Good luck
Harold
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top