|
Prev: How do I modify a table of contents with a VBA macro?
Next: Text to Speech: How do i read text in paragraph and highlight word
From: MathTeacher on 2 Jul 2008 19:05 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
From: Greg Maxey on 4 Jul 2008 23:40 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...(a)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
From: MathTeacher on 5 Jul 2008 00:40 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...(a)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 > >
From: Gregory K. Maxey on 5 Jul 2008 00:53 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...(a)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
From: MathTeacher on 5 Jul 2008 12:21
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...(a)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 > > > |