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

Re: VBA macro for Picture Formatting by Greg

Greg
Fri Jul 04 20:40:35 PDT 2008

Try:

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


On Jul 2, 7:05=A0pm, MathTeacher <MathTeac...@discussions.microsoft.com>
wrote:
> 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 wrap=
ping
> I want.
>
> Sub Macro3()
> =A0 =A0 Dim MyShape As Shape
> =A0 =A0 Set MyShape =3D Selection.InlineShapes(1).ConvertToShape
> =A0 =A0 MyShape.WrapFormat.Type =3D wdWrapSquare
> =A0 =A0 MyShape.RelativeHorizontalPosition =3D wdRelativeHorizontalPositi=
onMargin
> =A0 =A0 myShapeRange.Align msoAlignRight, True
> End Sub
>
> Thx, Jim


Re: VBA macro for Picture Formatting by MathTeacher

MathTeacher
Fri Jul 04 21:40:00 PDT 2008

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

"Greg Maxey" wrote:

> 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
>
>
> On Jul 2, 7:05 pm, MathTeacher <MathTeac...@discussions.microsoft.com>
> wrote:
> > 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
>
>

Re: VBA macro for Picture Formatting by Gregory

Gregory
Fri Jul 04 21:53:28 PDT 2008

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

Change:

MyShape.Left = InchesToPoints(0)

To:

MyShape.Left = wdShapeRight


MathTeacher wrote:
> 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
>
> "Greg Maxey" wrote:
>
>> 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
>>
>>
>> On Jul 2, 7:05 pm, MathTeacher
>> <MathTeac...@discussions.microsoft.com> wrote:
>>> 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



Re: VBA macro for Picture Formatting by MathTeacher

MathTeacher
Sat Jul 05 09:21:01 PDT 2008

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

"Gregory K. Maxey" wrote:

> Duh!! I should have read the question a little better ;-)
>
> Change:
>
> MyShape.Left = InchesToPoints(0)
>
> To:
>
> MyShape.Left = wdShapeRight
>
>
> MathTeacher wrote:
> > 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
> >
> > "Greg Maxey" wrote:
> >
> >> 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
> >>
> >>
> >> On Jul 2, 7:05 pm, MathTeacher
> >> <MathTeac...@discussions.microsoft.com> wrote:
> >>> 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
>
>
>

Re: VBA macro for Picture Formatting by Gregory

Gregory
Sat Jul 05 11:42:43 PDT 2008

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



MathTeacher wrote:
> 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
>
> "Gregory K. Maxey" wrote:
>
>> Duh!! I should have read the question a little better ;-)
>>
>> Change:
>>
>> MyShape.Left = InchesToPoints(0)
>>
>> To:
>>
>> MyShape.Left = wdShapeRight
>>
>>
>> MathTeacher wrote:
>>> 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
>>>
>>> "Greg Maxey" wrote:
>>>
>>>> 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
>>>>
>>>>
>>>> On Jul 2, 7:05 pm, MathTeacher
>>>> <MathTeac...@discussions.microsoft.com> wrote:
>>>>> 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



Re: VBA macro for Picture Formatting by Jonathan

Jonathan
Sat Jul 05 14:12:16 PDT 2008


"MathTeacher" <MathTeacher@discussions.microsoft.com> wrote in message
news:AA582DAE-9FC4-4D12-B6C3-98AD08F647FA@microsoft.com...
> 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.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup