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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.