From: Mary Fetsch on
In Word 2007, I adjust the text wrapping around a picture by right-clicking
on the picture and then choosing Format Picture, Layout, Advanced, Through.
I'll be very grateful to anyone who can tell me the Visual Basic code for
this.

Mary Fetsch
From: Jay Freedman on
On Mon, 31 May 2010 15:27:01 -0700, Mary Fetsch
<MaryFetsch(a)discussions.microsoft.com> wrote:

>In Word 2007, I adjust the text wrapping around a picture by right-clicking
>on the picture and then choosing Format Picture, Layout, Advanced, Through.
>I'll be very grateful to anyone who can tell me the Visual Basic code for
>this.
>
>Mary Fetsch

It can get a little complicated in code. A picture can be in line with
text, or it can be floating. In VBA, in-line pictures are one kind of
object and floating pictures are a completely different kind. Although
you can convert the kinds from one to the other, you can't just say
"fix this picture".

When you use the Format Picture dialog, it can do the conversion
silently and let you go from in-line to any one of the floating
variations. In code, you have to do something like this:

Sub demo()
If Selection.InlineShapes.Count > 0 Then
HandleInlineShape Selection.InlineShapes(1)
ElseIf Selection.ShapeRange.Count > 0 Then
HandleShape Selection.ShapeRange(1)
Else
MsgBox "Please select a picture first.", , _
"Wrong Selection"
End If
End Sub

Private Sub HandleInlineShape(ils As InlineShape)
Dim tempShp As Shape
Set tempShp = ils.ConvertToShape
HandleShape tempShp
End Sub

Private Sub HandleShape(shp As Shape)
shp.WrapFormat.Type = wdWrapThrough
End Sub

If you start out with an in-line picture (an InlineShape object),
first it gets passed to the HandleInlineShape macro, which converts it
to a floating shape and passes it to the HandleShape macro. If you
start out with a floating picture already (a Shape object), it gets
passed directly to the HandleShape macro. In either case, the final
step is to assign the desired wrapping type to it.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
From: Mary Fetsch on
Thank you SO much, Jay. I've really been struggling with this. Your macro
will be such a timesaver.

"Jay Freedman" wrote:

> On Mon, 31 May 2010 15:27:01 -0700, Mary Fetsch
> <MaryFetsch(a)discussions.microsoft.com> wrote:
>
> >In Word 2007, I adjust the text wrapping around a picture by right-clicking
> >on the picture and then choosing Format Picture, Layout, Advanced, Through.
> >I'll be very grateful to anyone who can tell me the Visual Basic code for
> >this.
> >
> >Mary Fetsch
>
> It can get a little complicated in code. A picture can be in line with
> text, or it can be floating. In VBA, in-line pictures are one kind of
> object and floating pictures are a completely different kind. Although
> you can convert the kinds from one to the other, you can't just say
> "fix this picture".
>
> When you use the Format Picture dialog, it can do the conversion
> silently and let you go from in-line to any one of the floating
> variations. In code, you have to do something like this:
>
> Sub demo()
> If Selection.InlineShapes.Count > 0 Then
> HandleInlineShape Selection.InlineShapes(1)
> ElseIf Selection.ShapeRange.Count > 0 Then
> HandleShape Selection.ShapeRange(1)
> Else
> MsgBox "Please select a picture first.", , _
> "Wrong Selection"
> End If
> End Sub
>
> Private Sub HandleInlineShape(ils As InlineShape)
> Dim tempShp As Shape
> Set tempShp = ils.ConvertToShape
> HandleShape tempShp
> End Sub
>
> Private Sub HandleShape(shp As Shape)
> shp.WrapFormat.Type = wdWrapThrough
> End Sub
>
> If you start out with an in-line picture (an InlineShape object),
> first it gets passed to the HandleInlineShape macro, which converts it
> to a floating shape and passes it to the HandleShape macro. If you
> start out with a floating picture already (a Shape object), it gets
> passed directly to the HandleShape macro. In either case, the final
> step is to assign the desired wrapping type to it.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
> .
>