PDA

View Full Version : Hide/Show all images in a word document by macro



Public81
03-20-2014, 01:59 AM
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

Public81
03-20-2014, 03:01 AM
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

macropod
03-20-2014, 03:18 PM
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.

Public81
03-21-2014, 02:36 AM
Thanks a lot mate, it worked. priceless.

Best regards