I got a long document with a lot of "floating" graphics which should
be formatted to be "inline" with text and centered.
I tried to write the macro using the macro recorder first but could
not access the necessary graphic properties.

How can I reformat All ! floating graphics from "floating" to "inline-
centered" with one macro?

Help is appreciated. Thank you very much in advance.

Regards, Andreas

Re: Switch all graphics in a document from "floating" to "inline-centered" by Greg

Greg
Tue Apr 17 07:22:45 CDT 2007

Andreas,

Very limited testing ;-)

Sub ScratchMacro()
Dim oShape As Shape
For Each oShape In ActiveDocument.Shapes
oShape.WrapFormat.Type = wdWrapInline
oShape.Anchor.Paragraphs(1).Alignment = wdAlignParagraphCenter
Next
End Sub


On Apr 17, 7:45 am, andreas <andreas.her...@gmx.de> wrote:
> I got a long document with a lot of "floating" graphics which should
> be formatted to be "inline" with text and centered.
> I tried to write the macro using the macro recorder first but could
> not access the necessary graphic properties.
>
> How can I reformat All ! floating graphics from "floating" to "inline-
> centered" with one macro?
>
> Help is appreciated. Thank you very much in advance.
>
> Regards, Andreas



Re: Switch all graphics in a document from "floating" to "inline-centered" by Helmut

Helmut
Tue Apr 17 07:36:26 CDT 2007

Hi Andreas,

Sub Test405()
Dim oShp As Shape
For Each oShp In ActiveDocument.Shapes
oShp.ConvertToInlineShape
Next
End Sub

If I select an inlineshape and look at "format picture", "layout",
"wrapping style", then all options in "horizontal alignment"
are greyed out. Understandably, as centered and inline with text are,
as far as I see, not compatible.

There is a horizontallineformat property of an inlineshape,
but this seems to be somewhat misleading.
At least I coundn't get it to do anything sensible.

However, if there is no text in the paragraph,
which holds the inlineshape, then centering that paragraph
might be what you want.

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



Re: Switch all graphics in a document from "floating" to "inline-centered" by andreas

andreas
Wed Apr 18 07:14:10 CDT 2007

On 17 Apr., 14:22, Greg Maxey <gma...@gmail.com> wrote:
> Andreas,
>
> Very limited testing ;-)
>
> Sub ScratchMacro()
> Dim oShape As Shape
> For Each oShape In ActiveDocument.Shapes
> oShape.WrapFormat.Type = wdWrapInline
> oShape.Anchor.Paragraphs(1).Alignment = wdAlignParagraphCenter
> Next
> End Sub
>
> On Apr 17, 7:45 am, andreas <andreas.her...@gmx.de> wrote:
>
>
>
> > I got a long document with a lot of "floating" graphics which should
> > be formatted to be "inline" with text and centered.
> > I tried to write the macro using the macro recorder first but could
> > not access the necessary graphic properties.
>
> > How can I reformat All ! floating graphics from "floating" to "inline-
> > centered" with one macro?
>
> > Help is appreciated. Thank you very much in advance.
>
> > Regards, Andreas- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Greg,
although your code looks logical from my point of view, it is not
working, i.e. graphics are not converted from floating to inline. But
as you said, it has not been tested.

The one below from Helmut is running fine. Thanks anyway Greg.

Regards, Andreas


Re: Switch all graphics in a document from "floating" to "inline-centered" by Greg

Greg
Wed Apr 18 07:38:49 CDT 2007

Andreas,

I got hung up "with all graphics." The problem
with .ConverttoInlineShape is that it would throw an error if it
encountered a drawing shape. Here is a slight modification to
Helmut's code that you might prefer:

Sub Test405()
Dim oShp As Shape
For Each oShp In ActiveDocument.Shapes
On Error GoTo Err_Handler
oShp.ConvertToInlineShape
ReEnter:
Next oShp
Exit Sub
Err_Handler:
If MsgBox("The current shape not of the type picture, OLE object or
ActiveX" _
& " control. Do you want to set the wrap format of this shape"
_
& " to inline?", vbYesNo, "Decision Point") = vbYes Then
oShp.WrapFormat.Type = wdWrapInline
oShp.Anchor.Paragraphs(1).Alignment = wdAlignParagraphCenter
Resume ReEnter
End If
End Sub

On Apr 18, 8:14 am, andreas <andreas.her...@gmx.de> wrote:
> On 17 Apr., 14:22, Greg Maxey <gma...@gmail.com> wrote:
>
>
>
>
>
> > Andreas,
>
> > Very limited testing ;-)
>
> > Sub ScratchMacro()
> > Dim oShape As Shape
> > For Each oShape In ActiveDocument.Shapes
> > oShape.WrapFormat.Type = wdWrapInline
> > oShape.Anchor.Paragraphs(1).Alignment = wdAlignParagraphCenter
> > Next
> > End Sub
>
> > On Apr 17, 7:45 am, andreas <andreas.her...@gmx.de> wrote:
>
> > > I got a long document with a lot of "floating" graphics which should
> > > be formatted to be "inline" with text and centered.
> > > I tried to write the macro using the macro recorder first but could
> > > not access the necessary graphic properties.
>
> > > How can I reformat All ! floating graphics from "floating" to "inline-
> > > centered" with one macro?
>
> > > Help is appreciated. Thank you very much in advance.
>
> > > Regards, Andreas- Zitierten Text ausblenden -
>
> > - Zitierten Text anzeigen -
>
> Greg,
> although your code looks logical from my point of view, it is not
> working, i.e. graphics are not converted from floating to inline. But
> as you said, it has not been tested.
>
> The one below from Helmut is running fine. Thanks anyway Greg.
>
> Regards, Andreas- Hide quoted text -
>
> - Show quoted text -



Re: Switch all graphics in a document from "floating" to "inline-centered" by andreas

andreas
Thu Apr 19 18:05:06 CDT 2007

On 17 Apr., 14:36, Helmut Weber <nbhymsjxd...@mailinator.com> wrote:
> Hi Andreas,
>
> Sub Test405()
> Dim oShp As Shape
> For Each oShp In ActiveDocument.Shapes
> oShp.ConvertToInlineShape
> Next
> End Sub
>
> If I select an inlineshape and look at "format picture", "layout",
> "wrapping style", then all options in "horizontal alignment"
> are greyed out. Understandably, as centered and inline with text are,
> as far as I see, not compatible.
>
> There is a horizontallineformat property of an inlineshape,
> but this seems to be somewhat misleading.
> At least I coundn't get it to do anything sensible.
>
> However, if there is no text in the paragraph,
> which holds the inlineshape, then centering that paragraph
> might be what you want.
>
> HTH
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"

Thank you Helmut for your assistance, It is working

Regards, Andreas