0

I am trying to reference a LOGO (the LOGO was inserted in the document as a picture) so that I can set its visible property to true or false as required. However I havent been able to find out how to reference the inserted picture file. Can anyone help me please.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Nelly1965
0

Hi,

Dealing with pictures in word is tricky. Because when you insert a picture to word it is inserted as inlineshape that is not allowed to be hidden through code. What you have to do is copy the picture >> edit >> paste special >> Ms office drawing object. Now remove the old logo and use the new pictures which can be treated as shape and set its visbility using: Me.Shapes("Picture 2").Visible = msoFalse to know the name of the shape use the following code:

Private Sub CommandButton1_Click()

Dim Sh As Shape
    For Each Sh In Me.Shapes
        Sh.Select
        MsgBox Sh.Name
    Next

End Sub
0

Hi,

Dealing with pictures in word is tricky. Because when you insert a picture to word it is inserted as inlineshape that is not allowed to be hidden through code. What you have to do is copy the picture >> edit >> paste special >> Ms office drawing object. Now remove the old logo and use the new pictures which can be treated as shape and set its visbility using: Me.Shapes("Picture 2").Visible = msoFalse to know the name of the shape use the following code:

Private Sub CommandButton1_Click()

Dim Sh As Shape
    For Each Sh In Me.Shapes
        Sh.Select
        MsgBox Sh.Name
    Next

End Sub

Thank you KB.NET. I have tried your solution which works great if the picture in the main document, but (just to be awkward) my picture is in the header of the document as it needs to appear on every page and it is not being listed as part of the shape collection? Any ideas

Thank you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.