Word 2003 macro for inserting icons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • loti20
    New Member
    • Aug 2006
    • 2

    #1

    Word 2003 macro for inserting icons

    I'm a technical writer and develop my documentation in Word. I'm looking to add icons, but want an easy way of doing so. I don't want to have to insert picture and format, or copy & paste, etc. So I started creating this macro. It works really well except for one thing... the very first time you try to run the macro in a document, it tries to insert the icon 3 lines above where my cursor is. Once i delete the bad icon and try again, it seems to work great. After that initial run, the macro inserts the icon in the right spot everytime... no matter where I place my cursor. any ideas what could be wrong?? here's my code...

    Sub InsertAndFormat Picture()
    'inserts a specific picture defined by PicturePath and Picture variables.

    Dim iILShape As Integer
    Dim iShape As Integer
    Dim PicturePath As String
    Dim Picture As String

    Application.Scr eenUpdating = False

    PicturePath = "N:\DOCUMENTATI ON\DocProjects\ Standards and Practices Committee\Conve ntions\"
    Picture = "Note - Small.png"

    Selection.HomeK ey Unit:=wdLine

    ActiveDocument. Shapes.AddPictu re FileName:=Pictu rePath & Picture, Anchor:=Selecti on.Range

    iShape = ActiveDocument. Shapes.Count

    ActiveDocument. Shapes(iShape). Select


    Selection.Shape Range.WrapForma t.Type = wdWrapNone
    Selection.Shape Range.LockAncho r = True
    'Selection.Shap eRange.ZOrder msoBringInFront OfText



    'ShapeIncrement = Selection.Parag raphFormat.Left Indent
    'ActiveDocument .Shapes(iShape) .IncrementLeft ShapeIncrement
    Selection.Shape Range.RelativeH orizontalPositi on = wdRelativeHoriz ontalPositionCh aracter
    Selection.Shape Range.Left = InchesToPoints(-0.5)

    Selection.HomeK ey Unit:=wdLine
    Selection.Parag raphFormat.Left Indent = InchesToPoints( 0.5)
    Selection.Parag raphs.Indent


    Selection.HomeK ey Unit:=wdLine
    Selection.Parag raphFormat.Left Indent = InchesToPoints( ParaIndent)
    Selection.Parag raphs.Indent



    Application.Scr eenUpdating = True
    End Sub
Working...