VBA macro for Picture Formatting

M

MathTeacher

Since I cannot record this operation as macro, I need some help with the VBA
to create the macro.

I want to select a picture (object) in MSWord and format it for Square
wrapping and aligned to the Right Margin. I have been through the objects and
methods and cannot find what I need. I used this to at least get the wrapping
I want.

Sub Macro3()
Dim MyShape As Shape
Set MyShape = Selection.InlineShapes(1).ConvertToShape
MyShape.WrapFormat.Type = wdWrapSquare
MyShape.RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
myShapeRange.Align msoAlignRight, True
End Sub

Thx, Jim
 
G

Greg Maxey

Try:

Sub Macro3()
Dim MyShape As Shape
Set MyShape = Selection.InlineShapes(1).ConvertToShape
MyShape.WrapFormat.Type = wdWrapSquare
MyShape.RelativeHorizontalPosition =
wdRelativeHorizontalPositionMargin
MyShape.Left = InchesToPoints(0)
End Sub
 
M

MathTeacher

Thanks Greg for the attempt, but that did not work. It set the distance from
the left margin to 0; basically left-justified. What I need is the
method/property that is equivalent to Alignment | Right | relative to Margin
in Word parlance. Found under Picture Formating | Layout | Advanced |
Hotizontal |Alignment.
Jim
 
G

Gregory K. Maxey

Duh!! I should have read the question a little better ;-)

Change:

MyShape.Left = InchesToPoints(0)

To:

MyShape.Left = wdShapeRight
 
M

MathTeacher

It works fine, thanks for the time and effort. I wish I could find a complete
list and description of all the Word VBA objects, properties and methods. The
MSDN on-line stuff is virtually impossible to navigate and is disjoint.

Jim
 
G

Gregory K. Maxey

Jim,

I just stumbled on it myself. After seeing that you didn't want left
alignment (easy enough). I recorded the process and teh constant
wdShapeRight appeared in the maze of recorded coded. F1 on wdShapeRight,
wdShapeLeft and wdShapeCenter produces no help found :-(.
 
J

Jonathan West

MathTeacher said:
It works fine, thanks for the time and effort. I wish I could find a
complete
list and description of all the Word VBA objects, properties and methods.
The
MSDN on-line stuff is virtually impossible to navigate and is disjoint.

In the VBA editor, press F2. You get the Object Browser window. You can
select any object in the left pane and it gives you a list of its methods
and properties in the right pane. Press F1 on any item to get its
description in the Help.

Another very good way of discovering what object is needed in order to
achieve something is to record a macro that does something fairly close, and
then look at the recorded code and see what objects it has used. I've been
programming Word VBA since the first version that had VBA (Word 97), and I
*still* do that from time to time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top