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 / May 2008

Tip: Looking for answers? Try searching our database.

Recording text wrapping layout options macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
reclusive monkey - 22 May 2008 12:39 GMT
Hello,

I would like to record a macro which will allow me to change a bunch
of settings for an inserted image. However, when I start to record the
Text Wrapping --> More Layout Options is greyed out. Is there a way
round this or is it not possible to access the Layout Options via VBA?
Thanks in advance.
Jay Freedman - 23 May 2008 01:13 GMT
>Hello,
>
[quoted text clipped - 3 lines]
>round this or is it not possible to access the Layout Options via VBA?
>Thanks in advance.

It certainly is possible to access the options through VBA -- but not by using
the recorder. You'll have to modify the recorded macro manually (see
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm).

If the inserted image is in line with text, it will be an InlineShape object --
the recorded code will be something like

Selection.InlineShapes.AddPicture FileName:="C:\pic.jpg"

First you have to assign it to a variable, by making these changes (note the
added parentheses):

Dim myInlineShp As InlineShape
Set myInlineShp = Selection.InlineShapes.AddPicture(FileName:="C:\pic.jpg")

Then you have to convert that to a Shape object, which VBA stores in a different
object collection:

Dim myShp As Shape
Set myShp = myInlineShp.ConvertToShape

Finally you can modify the shape's .WrapFormat object, which has a property for
each of the items in the Layout Options dialog page:

With myShp.WrapFormat
  .Type = wdWrapSquare
  .DistanceTop = 24  ' points
  ' etc.
End With

If the original picture is inserted with any wrapping other than In Line With
Text, then the recorded text will use ActiveDocument.Shapes.AddPicture. You can
assign that directly to a Shape object (again using the Set keyword) and skip
the part about converting from an InlineShape.

--
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.
 
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.