Format Picture

F

FGM

Word 2002 Windows 2000

I am using vba to insert a jpg. However, I would like the layout to be
behinde text and cannot figure out how to add that to my vba coding. Just by
inserting then the user can not move the jpg in the word document by dragging
it.

Thanks...
 
J

Jay Freedman

If you're simply pasting the picture from the clipboard, it's
defaulting to being in line with text. That's why you can't drag it.
Instead, you should insert it from a file as a floating shape to begin
with.

The method works like this:

Dim oShp As Shape

Set oShp = ActiveDocument.Shapes.AddPicture( _
FileName:="C:\path\MyPicture.jpg", _
LinkToFile:=False, _
SaveWithDocument:=True, _
Anchor:=Selection.Range)
With oShp
' the next two lines do "behind text"
.WrapFormat.Type = wdWrapNone
.ZOrder msoSendBehindText

' other attributes are optional
.Left = InchesToPoints(0.25)
.LockAspectRatio = msoTrue
.Width = InchesToPoints(1.75)
End With

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
F

FGM

Thak you that works great...

Jay Freedman said:
If you're simply pasting the picture from the clipboard, it's
defaulting to being in line with text. That's why you can't drag it.
Instead, you should insert it from a file as a floating shape to begin
with.

The method works like this:

Dim oShp As Shape

Set oShp = ActiveDocument.Shapes.AddPicture( _
FileName:="C:\path\MyPicture.jpg", _
LinkToFile:=False, _
SaveWithDocument:=True, _
Anchor:=Selection.Range)
With oShp
' the next two lines do "behind text"
.WrapFormat.Type = wdWrapNone
.ZOrder msoSendBehindText

' other attributes are optional
.Left = InchesToPoints(0.25)
.LockAspectRatio = msoTrue
.Width = InchesToPoints(1.75)
End With

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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