Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture layout in Word 2000

Status
Not open for further replies.

pippi1814

Programmer
Feb 9, 2004
6
0
0
NL
I'm trying to put a picture in a Word document, with the code:
Selection.InlineShapes.AddPicture FileName:= "C:\picture.jpg\", LinkToFile:=False, SaveWithDocument:=True

That works fine, but I want the wrapping style to be quare and outlined on the right side of the paper. How do I do that through code? I've been trying several things, but I just don't get it to work.
 
Hi Pippi,

If there is only one picture in this document! (the one you insert)
You can use this:
Sub InsertPicture()

ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, FileName:= _
"C:\Documents and Settings\Joost\Bureaublad\Hills.bmp", LinkToFile:=False _
, SaveWithDocument:=True).WrapFormat.Type = wdWrapSquare
ActiveDocument.Shapes.SelectAll
Selection.ShapeRange.Left = wdShapeRight

End Sub

Else if there is more then one picture, you would need there adres (bookmark)

Enjoy,
Joost Verdaasdonk
 
Unfortunately, sometimes there's more than one picture in the document. Do you know how to solve that?
 
You can instantiate a Shape object and then play with this properties, something like this:
Set myShape=ActiveDocument.Shapes.AddPicture( FileName:= "C:\picture.jpg\", LinkToFile:=False, SaveWithDocument:=True, Anchor:=Selection.Range)
myShape.WrapFormat.Type = wdWrapSquare
myShape.WrapFormat.Side = wdWrapRight
...
Set myShape = Nothing

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Hi Ph & Pippi,

To make the picture WrapSquare en Outline to the right it has to be somthing like this: (with help offcourse to Ph who made it variable)

Sub InsertPicture()
Set myShape = ActiveDocument.Shapes.AddPicture(FileName:="C:\Documents and Settings\Joost\Bureaublad\Hills.bmp", LinkToFile:=False, SaveWithDocument:=True, Anchor:=Selection.Range)
myShape.WrapFormat.Type = wdWrapSquare
myShape.Select
Selection.ShapeRange.Left = wdShapeRight
Set myShape = Nothing
End Sub

This types the picture to the insertion point and aligment is to the right for every picture you insert. (so it follows the cursor)

Enjoy,
Joost Verdaasdonk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top