View Single Post
 
Old 11-04-2019, 10:01 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Insert a shape rather than a text box
Code:
Sub SetWindowUp()

Dim winMain As Window
Dim Box As Shape
Dim x As Double, y As Double
Dim sPath As String
    sPath = Environ("USERPROFILE") & Chr(92) & "Pictures\"
    For Each winMain In Windows
        winMain.View.Zoom.Percentage = 100
    Next winMain
    Application.ActiveWindow.View.Type = WdViewType.wdPrintView

    x = Selection.Information(wdHorizontalPositionRelativeToPage)
    y = Selection.Information(wdVerticalPositionRelativeToPage)

    Set Box = ActiveDocument.Shapes.AddPicture _
              (FileName:=sPath & "\wheelchair access.png", _
               LinkToFile:=False, _
               SaveWithDocument:=True, _
               Left:=x, Top:=y, Width:=50, Height:=50)
End Sub
The file path in your original effort does not contain an insertable graphic, however the attached is an insertable version of that image, which you should save in your Pictures folder for it to work with the code above.

Personally I would probably just insert an inline shape at the cursor

Code:
Sub InsertIcon()
Dim winMain As Window
Dim Box As InlineShape
Dim x As Double, y As Double
Dim sPath As String
    sPath = Environ("USERPROFILE") & Chr(92) & "Pictures\"
    Application.ActiveWindow.View.Type = WdViewType.wdPrintView

    Set Box = Selection.Range.InlineShapes.AddPicture _
              (FileName:=sPath & "\wheelchair access.png", _
               LinkToFile:=False, _
               SaveWithDocument:=True)
    With Box
        .Width = 50
        .Height = 50
    End With
End Sub
Attached Images
File Type: png wheelchair access.png (2.9 KB, 19 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote