Changing picture layout from vba

W

WayneM

I am using VB6 to control Word and importing a picture object into Word.
When the picture is imported, I cannot move or reposition it without clicking
on the Format | Picture menu then selecting the Layout tab and then clicking
on the Tight mode (or another mode). After I do this, I can move the object.

The problem is that I cannot do this when I start a macro and I do not know
how to do this in code. Is there a better way to do this in code?

Thanks in advance,

WayneM
 
J

Jay Freedman

WayneM said:
I am using VB6 to control Word and importing a picture object into Word.
When the picture is imported, I cannot move or reposition it without clicking
on the Format | Picture menu then selecting the Layout tab and then clicking
on the Tight mode (or another mode). After I do this, I can move the object.

The problem is that I cannot do this when I start a macro and I do not know
how to do this in code. Is there a better way to do this in code?

Thanks in advance,

WayneM

Hi Wayne,

The reason you can't move the picture is that it's being inserted as
an inline shape -- Word treats it as a single large character within
the text layer. When you change the wrapping to Tight or Square or
whatever, that changes it from inline to floating in the drawing
layer.

You could change the inline shape to floating with code like this:
ActiveDocument.InlineShapes(1).ConvertToShape

But it might be better to insert the picture as a floating shape to
begin with. I don't know what method you're using now (Paste?), but
this sample will insert the named picture with Square wrapping and
position it 1.25 inches from the left margin. Look in the VBA help for
the other properties of the Shape object that you can adjust.

Dim oShape As Shape
Set oShape = ActiveDocument.Shapes.AddPicture( _
FileName:="c:\clips\4cup.gif", _
Anchor:=Selection.Range)
With oShape
.WrapFormat.Type = wdWrapSquare
.Left = InchesToPoints(1.25)
.LockAnchor = True
End With
 

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