Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

Switch all graphics in a document from "floating" to "inline-centered"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andreas - 17 Apr 2007 12:45 GMT
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
Greg Maxey - 17 Apr 2007 13:22 GMT
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 -
Helmut Weber - 17 Apr 2007 13:36 GMT
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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.