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
> I got a long document with a lot of "floating" graphics which should
> be formatted to be "inline" with text and centered.
[quoted text clipped - 7 lines]
>
> Regards, Andreas
andreas - 18 Apr 2007 13:14 GMT
> Andreas,
>
[quoted text clipped - 21 lines]
>
> - 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
Greg Maxey - 18 Apr 2007 13:38 GMT
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
> > Andreas,
>
[quoted text clipped - 32 lines]
>
> - Show quoted text -
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

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
andreas - 20 Apr 2007 00:05 GMT
> Hi Andreas,
>
[quoted text clipped - 27 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
Thank you Helmut for your assistance, It is working
Regards, Andreas