Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all images in word document [closed]

Tags:

ms-word

I need to do some formatting changes in a word document. For which I need to select all Images in the document.

Can someone provide me a macro/option just to select all images in a word document (I am using MS office 2007).

like image 544
user1891574 Avatar asked Dec 10 '12 12:12

user1891574


People also ask

How do I select all pictures in Word?

To select multiple objects, press and hold Ctrl while you click or tap the objects that you want. To select text with similar formatting, choose Select All Text with Similar Formatting.

How do I fix select all in Word?

According to your description, please try to right-click the status bar at the bottom of the Word and check the "Selection Mode" option, then check if the "Extended Selection" mode is turned on, if so, you can press ESC to turn it off.


1 Answers

I don't believe there is a simple way to select all images at once unless they are all In Line with Text. If they are, then you can loop them through to make formatting changes using the following example:

Dim iShape As InlineShape

For Each iShape In ActiveDocument.InlineShapes
    With iShape
        .Width = InchesToPoints(2)
        .Height = InchesToPoints(1.5)
    End With
Next iShape

I'm not sure if you want to format the pictures or some text around the pictures, but you can do either (or both).

If the images are not all In Line with Text, then you probably want to build something around the following, which moves you to the next graphic:

Selection.GoTo What:=wdGoToGraphic, Which:=wdGoToNext, Count:=1, Name:=""

The difference with this code is that it puts the cursor in front of the next graphic, but it doesn't actually select it, so you would need to add to it. If you wanted to loop through an entire document, here's some code that will do just that. It will find each graphic and type the word "Test" before it... until it finds no more graphics.

Selection.HomeKey unit:=wdStory
Do Until ActiveDocument.Bookmarks("\Sel") = ActiveDocument.Bookmarks("\EndOfDoc")
    Selection.GoTo What:=wdGoToGraphic, Which:=wdGoToNext, Count:=1, Name:=""
    Selection.MoveRight unit:=wdWord, Count:=1, Extend:=True
        If Selection.Type = 7 Then
            Selection.Collapse wdCollapseStart
            Selection.TypeText Text:="TEST"
            Selection.MoveRight unit:=wdWord, Count:=1, Extend:=False
        Else
            Exit Sub
        End If
Loop

It would help if we knew exactly what you were trying to do.

like image 88
Mike Avatar answered Oct 01 '22 00:10

Mike