Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Insert autoshape (Word 2000)

    I insert an autoshape using a macro I recorded. Is there a way that I can modify the code so that the autoshape is not positioned according to the recorded distances, but that it will be inserted at the insertion point?
    Here is the code:
    ActiveDocument.Shapes.AddShape(msoShapeLineCallout 3AccentBar, 166.5, _
    301.25, 92#, 48#).Select
    Selection.ShapeRange.TextFrame.TextRange.Select
    Selection.ShapeRange.Select
    Selection.ShapeRange.ScaleHeight 0.47, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.line.BeginArrowheadStyle = msoArrowheadTriangle
    Selection.ShapeRange.line.ForeColor.RGB = RGB(255, 0, 0) ' Red colour line
    Selection.ShapeRange.line.Weight = 1.5 ' Line weight 1.5
    Regards

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Insert autoshape (Word 2000)

    Try this:

    With ActiveDocument.Shapes.AddShape( _
    msoShapeLineCallout3AccentBar, _
    Selection.Information(wdHorizontalPositionRelative ToPage), _
    Selection.Information(wdVerticalPositionRelativeTo Page), _
    92#, _
    48#)
    .ScaleHeight 0.47, msoFalse, msoScaleFromTopLeft
    With .Line
    .BeginArrowheadStyle = msoArrowheadTriangle
    .ForeColor.RGB = RGB(255, 0, 0) ' Red colour line
    .Weight = 1.5 ' Line weight 1.5
    End With
    End With

    This code uses Selection.Information to obtain the position of the insertion point/current selection. It also uses With ... End With to avoid selecting the object.

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert autoshape (Word 2000)

    Perfect.
    Thanks Hans

  4. #4
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert autoshape (Word 2000)

    Hans, in addition I find now that I also want to flip the box so that the arrow points to the right with paragraph right aligned.
    The code I tried does not work.
    Please help
    Regards

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Insert autoshape (Word 2000)

    The position of the arrow can be changed by setting .Adjustments(1). You will have to experiment to get the correct value.
    The text alignment can be set through the TextFrame property:

    With ActiveDocument.Shapes.AddShape(...)
    ...
    .Adjustments(1) = 1.5
    .TextFrame.TextRange.ParagraphFormat.Alignment = wdAlignParagraphRight
    End With

  6. #6
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert autoshape (Word 2000)

    Thanks again Hans.
    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •