Consulting

Results 1 to 4 of 4

Thread: Hide/Show all images in a word document by macro

  1. #1

    Hide/Show all images in a word document by macro

    Hi all,
    i try to get a vba code to show or hide all images in my word document.
    maybe accessible through a box that you can click or an assigned button.
    thanks for your help u guys. much appreciated.
    greets

  2. #2
    Is it maybe an option to loop through all bookmarked images in the document to hide/show them? The first picture should stay in it.

    This is a code that at least works for one bookmarked picture.

    Dim boolhidden As Boolean
    If ActiveWindow.View.ShowHiddenText = True Then
    boolhidden = True
    Else
    boolhidden = False
    End If
    If boolhidden = True Then
    ActiveWindow.View.ShowHiddenText = False
    End If
    With ActiveDocument.Bookmarks("Picture1").Range.Font
    If .Hidden = True Then
    .Hidden = False
    Else
    .Hidden = True
    If boolhidden = True Then
    ActiveWindow.View.ShowHiddenText = True
    End If
    End If
    End With

    Thanks in advance

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Try:
    Sub Demo()
    Dim Shp As Shape, iShp As InlineShape
    With ActiveDocument
      For Each iShp In .InlineShapes
        iShp.Range.Font.Hidden = True
      Next
      For Each Shp In .Shapes
        Shp.Anchor.Font.Hidden = True
      Next
    End With
    End Sub
    To unhide, simply change the two False statements to True

    Note: whether the images remain visible, or print, depends on how the user has Word configured.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    Thanks a lot mate, it worked. priceless.

    Best regards

Tags for this Thread

Posting Permissions

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