How to browse for embedded pictures?

G

Guest

In Word 2000 and Word 2003, the "browse by" tool contains no provision for
embedded pictures. (I use both versions.) I have some documents with various
types of graphics and pictures: equations, imported bitmaps, imported jpegs.
The "browse by graphic" finds equations, but not the others. I have
determined that it will find them if I set the pictures to show "inline with
text," but I need to format them in "tight" mode, or sometimes "In front of
text," both options that put the picture on a different layer. At that point
neither the browse tool nor the find function can locate them, because those
tools only work on the text layer.

Is there any way to change this, or write a macro to do what I want? When I
used Wordperfect, I had no problem searching for any types of graphics. When
I want to check the final formatting in Word, I have to hunt for them
visually.

RB
 
M

macropod

Hi RB,

You could use a macro like the following to go through the floating shapes.

Sub FindShapes()
Dim i As Integer
Dim Result As Integer
With ActiveDocument
If .Shapes.Count > 0 Then
For i = 1 To .Shapes.Count
Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
If Result = vbNo Then
.Shapes(i).Select
Exit Sub
End If
Next
MsgBox "Finished."
End If
End With
End Sub

As coded, if you tell the macro to stop searching before it's finished, it'll leave the last identified shape selected.

Cheers

--
macropod
[MVP - Microsoft Word]


| In Word 2000 and Word 2003, the "browse by" tool contains no provision for
| embedded pictures. (I use both versions.) I have some documents with various
| types of graphics and pictures: equations, imported bitmaps, imported jpegs.
| The "browse by graphic" finds equations, but not the others. I have
| determined that it will find them if I set the pictures to show "inline with
| text," but I need to format them in "tight" mode, or sometimes "In front of
| text," both options that put the picture on a different layer. At that point
| neither the browse tool nor the find function can locate them, because those
| tools only work on the text layer.
|
| Is there any way to change this, or write a macro to do what I want? When I
| used Wordperfect, I had no problem searching for any types of graphics. When
| I want to check the final formatting in Word, I have to hunt for them
| visually.
|
| RB
 
G

Guest

Macropod, thanks.

I copied and pasted the macro, and it works, sort of, but not quite the way
I imagined. It finds pictures that are formatted as "tight" , but not those
formatted with text wrapping set for "top and bottom." Also, when it finds a
shape, it doesn't take me there. I have to say "no" to the dialogue, then use
the "browse edits" tool to move to the selected picture. Then, when I run the
macro again, it starts over at the top again, so I have to remember the
sequence of pictures and keep saying "yes" until I reach the one I want to to
look at. In other words, I almost have to know where they are so I can search
for them. In the document I tried the macro on, for instance, the first
picture was "235." After I used browse edits to reach 235, and ran the macro
again, I said "yes" to 235, and "no" to 236, and then used browse edits to
reach that. And so on. A bit cumbersome. Are there any other tweaks that
might be written into the macro? I used to write lots of fancy macros in the
the old wordperfect for DOS programs, but haven't done much but keystroke
macros in Word, so I'm a bit rusty.

Thanks

RB

macropod said:
Hi RB,

You could use a macro like the following to go through the floating shapes.

Sub FindShapes()
Dim i As Integer
Dim Result As Integer
With ActiveDocument
If .Shapes.Count > 0 Then
For i = 1 To .Shapes.Count
Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
If Result = vbNo Then
.Shapes(i).Select
Exit Sub
End If
Next
MsgBox "Finished."
End If
End With
End Sub

As coded, if you tell the macro to stop searching before it's finished, it'll leave the last identified shape selected.

Cheers

--
macropod
[MVP - Microsoft Word]


| In Word 2000 and Word 2003, the "browse by" tool contains no provision for
| embedded pictures. (I use both versions.) I have some documents with various
| types of graphics and pictures: equations, imported bitmaps, imported jpegs.
| The "browse by graphic" finds equations, but not the others. I have
| determined that it will find them if I set the pictures to show "inline with
| text," but I need to format them in "tight" mode, or sometimes "In front of
| text," both options that put the picture on a different layer. At that point
| neither the browse tool nor the find function can locate them, because those
| tools only work on the text layer.
|
| Is there any way to change this, or write a macro to do what I want? When I
| used Wordperfect, I had no problem searching for any types of graphics. When
| I want to check the final formatting in Word, I have to hunt for them
| visually.
|
| RB
 
M

macropod

Hi,

To select the starting shape # and make the document scroll to and select each found shape as you go, you could use:

Sub FindShapes()
Dim i As Integer
Dim Result As Integer
With ActiveDocument
If .Shapes.Count > 0 Then
For i = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
& vbCrLf & "Please Input the Shape # to start your search at."))) To .Shapes.Count
.Shapes(i).Select
Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
.Shapes(i).Select
Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
If Result = vbNo Then
Exit Sub
End If
Next
MsgBox "Finished."
End If
End With
End Sub

I don't have any difficulty with the macro selecting shaps formatted with text wrapping set for "top and bottom".

Cheers

--
macropod
[MVP - Microsoft Word]


| Macropod, thanks.
|
| I copied and pasted the macro, and it works, sort of, but not quite the way
| I imagined. It finds pictures that are formatted as "tight" , but not those
| formatted with text wrapping set for "top and bottom." Also, when it finds a
| shape, it doesn't take me there. I have to say "no" to the dialogue, then use
| the "browse edits" tool to move to the selected picture. Then, when I run the
| macro again, it starts over at the top again, so I have to remember the
| sequence of pictures and keep saying "yes" until I reach the one I want to to
| look at. In other words, I almost have to know where they are so I can search
| for them. In the document I tried the macro on, for instance, the first
| picture was "235." After I used browse edits to reach 235, and ran the macro
| again, I said "yes" to 235, and "no" to 236, and then used browse edits to
| reach that. And so on. A bit cumbersome. Are there any other tweaks that
| might be written into the macro? I used to write lots of fancy macros in the
| the old wordperfect for DOS programs, but haven't done much but keystroke
| macros in Word, so I'm a bit rusty.
|
| Thanks
|
| RB
|
| "macropod" wrote:
|
| > Hi RB,
| >
| > You could use a macro like the following to go through the floating shapes.
| >
| > Sub FindShapes()
| > Dim i As Integer
| > Dim Result As Integer
| > With ActiveDocument
| > If .Shapes.Count > 0 Then
| > For i = 1 To .Shapes.Count
| > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| > If Result = vbNo Then
| > .Shapes(i).Select
| > Exit Sub
| > End If
| > Next
| > MsgBox "Finished."
| > End If
| > End With
| > End Sub
| >
| > As coded, if you tell the macro to stop searching before it's finished, it'll leave the last identified shape selected.
| >
| > Cheers
| >
| > --
| > macropod
| > [MVP - Microsoft Word]
| >
| >
| > | In Word 2000 and Word 2003, the "browse by" tool contains no provision for
| > | embedded pictures. (I use both versions.) I have some documents with various
| > | types of graphics and pictures: equations, imported bitmaps, imported jpegs.
| > | The "browse by graphic" finds equations, but not the others. I have
| > | determined that it will find them if I set the pictures to show "inline with
| > | text," but I need to format them in "tight" mode, or sometimes "In front of
| > | text," both options that put the picture on a different layer. At that point
| > | neither the browse tool nor the find function can locate them, because those
| > | tools only work on the text layer.
| > |
| > | Is there any way to change this, or write a macro to do what I want? When I
| > | used Wordperfect, I had no problem searching for any types of graphics. When
| > | I want to check the final formatting in Word, I have to hunt for them
| > | visually.
| > |
| > | RB
| >
| >
| >
 
G

Guest

Thanks, I'll give it a try later tonight.

RB

macropod said:
Hi,

To select the starting shape # and make the document scroll to and select each found shape as you go, you could use:

Sub FindShapes()
Dim i As Integer
Dim Result As Integer
With ActiveDocument
If .Shapes.Count > 0 Then
For i = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
& vbCrLf & "Please Input the Shape # to start your search at."))) To .Shapes.Count
.Shapes(i).Select
Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
.Shapes(i).Select
Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
If Result = vbNo Then
Exit Sub
End If
Next
MsgBox "Finished."
End If
End With
End Sub

I don't have any difficulty with the macro selecting shaps formatted with text wrapping set for "top and bottom".

Cheers

--
macropod
[MVP - Microsoft Word]


| Macropod, thanks.
|
| I copied and pasted the macro, and it works, sort of, but not quite the way
| I imagined. It finds pictures that are formatted as "tight" , but not those
| formatted with text wrapping set for "top and bottom." Also, when it finds a
| shape, it doesn't take me there. I have to say "no" to the dialogue, then use
| the "browse edits" tool to move to the selected picture. Then, when I run the
| macro again, it starts over at the top again, so I have to remember the
| sequence of pictures and keep saying "yes" until I reach the one I want to to
| look at. In other words, I almost have to know where they are so I can search
| for them. In the document I tried the macro on, for instance, the first
| picture was "235." After I used browse edits to reach 235, and ran the macro
| again, I said "yes" to 235, and "no" to 236, and then used browse edits to
| reach that. And so on. A bit cumbersome. Are there any other tweaks that
| might be written into the macro? I used to write lots of fancy macros in the
| the old wordperfect for DOS programs, but haven't done much but keystroke
| macros in Word, so I'm a bit rusty.
|
| Thanks
|
| RB
|
| "macropod" wrote:
|
| > Hi RB,
| >
| > You could use a macro like the following to go through the floating shapes.
| >
| > Sub FindShapes()
| > Dim i As Integer
| > Dim Result As Integer
| > With ActiveDocument
| > If .Shapes.Count > 0 Then
| > For i = 1 To .Shapes.Count
| > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| > If Result = vbNo Then
| > .Shapes(i).Select
| > Exit Sub
| > End If
| > Next
| > MsgBox "Finished."
| > End If
| > End With
| > End Sub
| >
| > As coded, if you tell the macro to stop searching before it's finished, it'll leave the last identified shape selected.
| >
| > Cheers
| >
| > --
| > macropod
| > [MVP - Microsoft Word]
| >
| >
| > | In Word 2000 and Word 2003, the "browse by" tool contains no provision for
| > | embedded pictures. (I use both versions.) I have some documents with various
| > | types of graphics and pictures: equations, imported bitmaps, imported jpegs.
| > | The "browse by graphic" finds equations, but not the others. I have
| > | determined that it will find them if I set the pictures to show "inline with
| > | text," but I need to format them in "tight" mode, or sometimes "In front of
| > | text," both options that put the picture on a different layer. At that point
| > | neither the browse tool nor the find function can locate them, because those
| > | tools only work on the text layer.
| > |
| > | Is there any way to change this, or write a macro to do what I want? When I
| > | used Wordperfect, I had no problem searching for any types of graphics. When
| > | I want to check the final formatting in Word, I have to hunt for them
| > | visually.
| > |
| > | RB
| >
| >
| >
 
G

Guest

Macropod,

I tried it, and it works perfectly; but now I'm a little confused as to how
these shapes are registered by Word. They don't show up in the order in which
they occur in the document. They seem to come up in the order of creation or
editing. So the first couple came in order, then the third one was skipped,
and so on; but the ones that were skipped came later, as the macro made more
passes. It is going by "shape no." How does Word assign shape numbers? In
this case, the first one was #235, which means, I guess, that I had 234
earlier versions that I've changed or deleted. The third shape in the text
was numbered 264. I don't find anywhere in the properties of these shapes to
assign them numbers manually, to make them show up in the right order. Is
there any way to do this?

You're being a great help, by the way. This problem has bedeviled me for
years.

Thanks

RB


macropod said:
Hi,

To select the starting shape # and make the document scroll to and select each found shape as you go, you could use:

Sub FindShapes()
Dim i As Integer
Dim Result As Integer
With ActiveDocument
If .Shapes.Count > 0 Then
For i = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
& vbCrLf & "Please Input the Shape # to start your search at."))) To .Shapes.Count
.Shapes(i).Select
Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
.Shapes(i).Select
Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
If Result = vbNo Then
Exit Sub
End If
Next
MsgBox "Finished."
End If
End With
End Sub

I don't have any difficulty with the macro selecting shaps formatted with text wrapping set for "top and bottom".

Cheers

--
macropod
[MVP - Microsoft Word]


| Macropod, thanks.
|
| I copied and pasted the macro, and it works, sort of, but not quite the way
| I imagined. It finds pictures that are formatted as "tight" , but not those
| formatted with text wrapping set for "top and bottom." Also, when it finds a
| shape, it doesn't take me there. I have to say "no" to the dialogue, then use
| the "browse edits" tool to move to the selected picture. Then, when I run the
| macro again, it starts over at the top again, so I have to remember the
| sequence of pictures and keep saying "yes" until I reach the one I want to to
| look at. In other words, I almost have to know where they are so I can search
| for them. In the document I tried the macro on, for instance, the first
| picture was "235." After I used browse edits to reach 235, and ran the macro
| again, I said "yes" to 235, and "no" to 236, and then used browse edits to
| reach that. And so on. A bit cumbersome. Are there any other tweaks that
| might be written into the macro? I used to write lots of fancy macros in the
| the old wordperfect for DOS programs, but haven't done much but keystroke
| macros in Word, so I'm a bit rusty.
|
| Thanks
|
| RB
|
| "macropod" wrote:
|
| > Hi RB,
| >
| > You could use a macro like the following to go through the floating shapes.
| >
| > Sub FindShapes()
| > Dim i As Integer
| > Dim Result As Integer
| > With ActiveDocument
| > If .Shapes.Count > 0 Then
| > For i = 1 To .Shapes.Count
| > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| > If Result = vbNo Then
| > .Shapes(i).Select
| > Exit Sub
| > End If
| > Next
| > MsgBox "Finished."
| > End If
| > End With
| > End Sub
| >
| > As coded, if you tell the macro to stop searching before it's finished, it'll leave the last identified shape selected.
| >
| > Cheers
| >
| > --
| > macropod
| > [MVP - Microsoft Word]
| >
| >
| > | In Word 2000 and Word 2003, the "browse by" tool contains no provision for
| > | embedded pictures. (I use both versions.) I have some documents with various
| > | types of graphics and pictures: equations, imported bitmaps, imported jpegs.
| > | The "browse by graphic" finds equations, but not the others. I have
| > | determined that it will find them if I set the pictures to show "inline with
| > | text," but I need to format them in "tight" mode, or sometimes "In front of
| > | text," both options that put the picture on a different layer. At that point
| > | neither the browse tool nor the find function can locate them, because those
| > | tools only work on the text layer.
| > |
| > | Is there any way to change this, or write a macro to do what I want? When I
| > | used Wordperfect, I had no problem searching for any types of graphics. When
| > | I want to check the final formatting in Word, I have to hunt for them
| > | visually.
| > |
| > | RB
| >
| >
| >
 
M

macropod

Hi RB,

Yes, Word keeps track of the shapes according to the order in which they were inserted, not the page on which they appear, and
there's no re-numbering to take account of deleted shapes. The code I posted before processes the shapes in insertion order.

Below you'll find a modified version of the code, which goes through the shapes in 'attached paragraph order'. With this version,
the shape number you assign in the input box refers to the shape's relative position in the document. If there's more than one shape
attached to a given paragraph, they're processed in insertion order. On exiting, you can even give the selected shape a meaningful
name - if you like. If you don't want that functionality, comment out the line starting with 'oShp.Name = '.

Sub FindShapes()
Dim oPara As Paragraph
Dim oShp As Shape
Dim i As Integer
Dim j As Integer
Dim Result As Integer
i = 0
j = 0
With ActiveDocument
If .Shapes.Count > 0 Then
j = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
& vbCrLf & "Please Input the Shape # to start your search at.")))
For Each oPara In .Paragraphs
If oPara.Range.ShapeRange.Count > 0 Then
For Each oShp In oPara.Range.ShapeRange
i = i + 1
If i >= j Then
oShp.Select
Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
oShp.Select
Result = MsgBox("Found Shape: " & oShp.Name & vbCrLf & "Continue Searching?", vbYesNo)
If Result = vbNo Then
oShp.Name = InputBox("Please give this shape (" & oShp.Name & vbCrLf & _
") a meaningful name")
Exit Sub
End If
End If
Next oShp
End If
Next oPara
MsgBox "Finished."
End If
End With
End Sub


Cheers

--
macropod
[MVP - Microsoft Word]


| Macropod,
|
| I tried it, and it works perfectly; but now I'm a little confused as to how
| these shapes are registered by Word. They don't show up in the order in which
| they occur in the document. They seem to come up in the order of creation or
| editing. So the first couple came in order, then the third one was skipped,
| and so on; but the ones that were skipped came later, as the macro made more
| passes. It is going by "shape no." How does Word assign shape numbers? In
| this case, the first one was #235, which means, I guess, that I had 234
| earlier versions that I've changed or deleted. The third shape in the text
| was numbered 264. I don't find anywhere in the properties of these shapes to
| assign them numbers manually, to make them show up in the right order. Is
| there any way to do this?
|
| You're being a great help, by the way. This problem has bedeviled me for
| years.
|
| Thanks
|
| RB
|
|
| "macropod" wrote:
|
| > Hi,
| >
| > To select the starting shape # and make the document scroll to and select each found shape as you go, you could use:
| >
| > Sub FindShapes()
| > Dim i As Integer
| > Dim Result As Integer
| > With ActiveDocument
| > If .Shapes.Count > 0 Then
| > For i = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
| > & vbCrLf & "Please Input the Shape # to start your search at."))) To .Shapes.Count
| > .Shapes(i).Select
| > Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
| > .Shapes(i).Select
| > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| > If Result = vbNo Then
| > Exit Sub
| > End If
| > Next
| > MsgBox "Finished."
| > End If
| > End With
| > End Sub
| >
| > I don't have any difficulty with the macro selecting shaps formatted with text wrapping set for "top and bottom".
| >
| > Cheers
| >
| > --
| > macropod
| > [MVP - Microsoft Word]
| >
| >
| > | Macropod, thanks.
| > |
| > | I copied and pasted the macro, and it works, sort of, but not quite the way
| > | I imagined. It finds pictures that are formatted as "tight" , but not those
| > | formatted with text wrapping set for "top and bottom." Also, when it finds a
| > | shape, it doesn't take me there. I have to say "no" to the dialogue, then use
| > | the "browse edits" tool to move to the selected picture. Then, when I run the
| > | macro again, it starts over at the top again, so I have to remember the
| > | sequence of pictures and keep saying "yes" until I reach the one I want to to
| > | look at. In other words, I almost have to know where they are so I can search
| > | for them. In the document I tried the macro on, for instance, the first
| > | picture was "235." After I used browse edits to reach 235, and ran the macro
| > | again, I said "yes" to 235, and "no" to 236, and then used browse edits to
| > | reach that. And so on. A bit cumbersome. Are there any other tweaks that
| > | might be written into the macro? I used to write lots of fancy macros in the
| > | the old wordperfect for DOS programs, but haven't done much but keystroke
| > | macros in Word, so I'm a bit rusty.
| > |
| > | Thanks
| > |
| > | RB
| > |
| > | "macropod" wrote:
| > |
| > | > Hi RB,
| > | >
| > | > You could use a macro like the following to go through the floating shapes.
| > | >
| > | > Sub FindShapes()
| > | > Dim i As Integer
| > | > Dim Result As Integer
| > | > With ActiveDocument
| > | > If .Shapes.Count > 0 Then
| > | > For i = 1 To .Shapes.Count
| > | > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| > | > If Result = vbNo Then
| > | > .Shapes(i).Select
| > | > Exit Sub
| > | > End If
| > | > Next
| > | > MsgBox "Finished."
| > | > End If
| > | > End With
| > | > End Sub
| > | >
| > | > As coded, if you tell the macro to stop searching before it's finished, it'll leave the last identified shape selected.
| > | >
| > | > Cheers
| > | >
| > | > --
| > | > macropod
| > | > [MVP - Microsoft Word]
| > | >
| > | >
| > | > | In Word 2000 and Word 2003, the "browse by" tool contains no provision for
| > | > | embedded pictures. (I use both versions.) I have some documents with various
| > | > | types of graphics and pictures: equations, imported bitmaps, imported jpegs.
| > | > | The "browse by graphic" finds equations, but not the others. I have
| > | > | determined that it will find them if I set the pictures to show "inline with
| > | > | text," but I need to format them in "tight" mode, or sometimes "In front of
| > | > | text," both options that put the picture on a different layer. At that point
| > | > | neither the browse tool nor the find function can locate them, because those
| > | > | tools only work on the text layer.
| > | > |
| > | > | Is there any way to change this, or write a macro to do what I want? When I
| > | > | used Wordperfect, I had no problem searching for any types of graphics. When
| > | > | I want to check the final formatting in Word, I have to hunt for them
| > | > | visually.
| > | > |
| > | > | RB
| > | >
| > | >
| > | >
| >
| >
| >
 
M

macropod

Two minor fixes:
1. After the line 'With ActiveDocument' add 'On Error Resume Next'. This will skip over errors caused by the failure to enter a
valid starting shape # or to input a valid shape name when prompted.
2. Delete 'vbCrLf &' on the line starting with 'oShp.Name = '.

Cheers

--
macropod
[MVP - Microsoft Word]


| Hi RB,
|
| Yes, Word keeps track of the shapes according to the order in which they were inserted, not the page on which they appear, and
| there's no re-numbering to take account of deleted shapes. The code I posted before processes the shapes in insertion order.
|
| Below you'll find a modified version of the code, which goes through the shapes in 'attached paragraph order'. With this version,
| the shape number you assign in the input box refers to the shape's relative position in the document. If there's more than one
shape
| attached to a given paragraph, they're processed in insertion order. On exiting, you can even give the selected shape a meaningful
| name - if you like. If you don't want that functionality, comment out the line starting with 'oShp.Name = '.
|
| Sub FindShapes()
| Dim oPara As Paragraph
| Dim oShp As Shape
| Dim i As Integer
| Dim j As Integer
| Dim Result As Integer
| i = 0
| j = 0
| With ActiveDocument
| If .Shapes.Count > 0 Then
| j = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
| & vbCrLf & "Please Input the Shape # to start your search at.")))
| For Each oPara In .Paragraphs
| If oPara.Range.ShapeRange.Count > 0 Then
| For Each oShp In oPara.Range.ShapeRange
| i = i + 1
| If i >= j Then
| oShp.Select
| Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
| oShp.Select
| Result = MsgBox("Found Shape: " & oShp.Name & vbCrLf & "Continue Searching?", vbYesNo)
| If Result = vbNo Then
| oShp.Name = InputBox("Please give this shape (" & oShp.Name & vbCrLf & _
| ") a meaningful name")
| Exit Sub
| End If
| End If
| Next oShp
| End If
| Next oPara
| MsgBox "Finished."
| End If
| End With
| End Sub
|
|
| Cheers
|
| --
| macropod
| [MVP - Microsoft Word]
|
|
| | Macropod,
| |
| | I tried it, and it works perfectly; but now I'm a little confused as to how
| | these shapes are registered by Word. They don't show up in the order in which
| | they occur in the document. They seem to come up in the order of creation or
| | editing. So the first couple came in order, then the third one was skipped,
| | and so on; but the ones that were skipped came later, as the macro made more
| | passes. It is going by "shape no." How does Word assign shape numbers? In
| | this case, the first one was #235, which means, I guess, that I had 234
| | earlier versions that I've changed or deleted. The third shape in the text
| | was numbered 264. I don't find anywhere in the properties of these shapes to
| | assign them numbers manually, to make them show up in the right order. Is
| | there any way to do this?
| |
| | You're being a great help, by the way. This problem has bedeviled me for
| | years.
| |
| | Thanks
| |
| | RB
| |
| |
| | "macropod" wrote:
| |
| | > Hi,
| | >
| | > To select the starting shape # and make the document scroll to and select each found shape as you go, you could use:
| | >
| | > Sub FindShapes()
| | > Dim i As Integer
| | > Dim Result As Integer
| | > With ActiveDocument
| | > If .Shapes.Count > 0 Then
| | > For i = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
| | > & vbCrLf & "Please Input the Shape # to start your search at."))) To .Shapes.Count
| | > .Shapes(i).Select
| | > Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
| | > .Shapes(i).Select
| | > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| | > If Result = vbNo Then
| | > Exit Sub
| | > End If
| | > Next
| | > MsgBox "Finished."
| | > End If
| | > End With
| | > End Sub
| | >
| | > I don't have any difficulty with the macro selecting shaps formatted with text wrapping set for "top and bottom".
| | >
| | > Cheers
| | >
| | > --
| | > macropod
| | > [MVP - Microsoft Word]
| | >
| | >
| | > | Macropod, thanks.
| | > |
| | > | I copied and pasted the macro, and it works, sort of, but not quite the way
| | > | I imagined. It finds pictures that are formatted as "tight" , but not those
| | > | formatted with text wrapping set for "top and bottom." Also, when it finds a
| | > | shape, it doesn't take me there. I have to say "no" to the dialogue, then use
| | > | the "browse edits" tool to move to the selected picture. Then, when I run the
| | > | macro again, it starts over at the top again, so I have to remember the
| | > | sequence of pictures and keep saying "yes" until I reach the one I want to to
| | > | look at. In other words, I almost have to know where they are so I can search
| | > | for them. In the document I tried the macro on, for instance, the first
| | > | picture was "235." After I used browse edits to reach 235, and ran the macro
| | > | again, I said "yes" to 235, and "no" to 236, and then used browse edits to
| | > | reach that. And so on. A bit cumbersome. Are there any other tweaks that
| | > | might be written into the macro? I used to write lots of fancy macros in the
| | > | the old wordperfect for DOS programs, but haven't done much but keystroke
| | > | macros in Word, so I'm a bit rusty.
| | > |
| | > | Thanks
| | > |
| | > | RB
| | > |
| | > | "macropod" wrote:
| | > |
| | > | > Hi RB,
| | > | >
| | > | > You could use a macro like the following to go through the floating shapes.
| | > | >
| | > | > Sub FindShapes()
| | > | > Dim i As Integer
| | > | > Dim Result As Integer
| | > | > With ActiveDocument
| | > | > If .Shapes.Count > 0 Then
| | > | > For i = 1 To .Shapes.Count
| | > | > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| | > | > If Result = vbNo Then
| | > | > .Shapes(i).Select
| | > | > Exit Sub
| | > | > End If
| | > | > Next
| | > | > MsgBox "Finished."
| | > | > End If
| | > | > End With
| | > | > End Sub
| | > | >
| | > | > As coded, if you tell the macro to stop searching before it's finished, it'll leave the last identified shape selected.
| | > | >
| | > | > Cheers
| | > | >
| | > | > --
| | > | > macropod
| | > | > [MVP - Microsoft Word]
| | > | >
| | > | >
| | > | > | In Word 2000 and Word 2003, the "browse by" tool contains no provision for
| | > | > | embedded pictures. (I use both versions.) I have some documents with various
| | > | > | types of graphics and pictures: equations, imported bitmaps, imported jpegs.
| | > | > | The "browse by graphic" finds equations, but not the others. I have
| | > | > | determined that it will find them if I set the pictures to show "inline with
| | > | > | text," but I need to format them in "tight" mode, or sometimes "In front of
| | > | > | text," both options that put the picture on a different layer. At that point
| | > | > | neither the browse tool nor the find function can locate them, because those
| | > | > | tools only work on the text layer.
| | > | > |
| | > | > | Is there any way to change this, or write a macro to do what I want? When I
| | > | > | used Wordperfect, I had no problem searching for any types of graphics. When
| | > | > | I want to check the final formatting in Word, I have to hunt for them
| | > | > | visually.
| | > | > |
| | > | > | RB
| | > | >
| | > | >
| | > | >
| | >
| | >
| | >
|
|
 
G

Guest

Macropod,

That did the trick. Perfect. I can't thank you enough.

RB

macropod said:
Hi RB,

Yes, Word keeps track of the shapes according to the order in which they were inserted, not the page on which they appear, and
there's no re-numbering to take account of deleted shapes. The code I posted before processes the shapes in insertion order.

Below you'll find a modified version of the code, which goes through the shapes in 'attached paragraph order'. With this version,
the shape number you assign in the input box refers to the shape's relative position in the document. If there's more than one shape
attached to a given paragraph, they're processed in insertion order. On exiting, you can even give the selected shape a meaningful
name - if you like. If you don't want that functionality, comment out the line starting with 'oShp.Name = '.

Sub FindShapes()
Dim oPara As Paragraph
Dim oShp As Shape
Dim i As Integer
Dim j As Integer
Dim Result As Integer
i = 0
j = 0
With ActiveDocument
If .Shapes.Count > 0 Then
j = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
& vbCrLf & "Please Input the Shape # to start your search at.")))
For Each oPara In .Paragraphs
If oPara.Range.ShapeRange.Count > 0 Then
For Each oShp In oPara.Range.ShapeRange
i = i + 1
If i >= j Then
oShp.Select
Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
oShp.Select
Result = MsgBox("Found Shape: " & oShp.Name & vbCrLf & "Continue Searching?", vbYesNo)
If Result = vbNo Then
oShp.Name = InputBox("Please give this shape (" & oShp.Name & vbCrLf & _
") a meaningful name")
Exit Sub
End If
End If
Next oShp
End If
Next oPara
MsgBox "Finished."
End If
End With
End Sub


Cheers

--
macropod
[MVP - Microsoft Word]


| Macropod,
|
| I tried it, and it works perfectly; but now I'm a little confused as to how
| these shapes are registered by Word. They don't show up in the order in which
| they occur in the document. They seem to come up in the order of creation or
| editing. So the first couple came in order, then the third one was skipped,
| and so on; but the ones that were skipped came later, as the macro made more
| passes. It is going by "shape no." How does Word assign shape numbers? In
| this case, the first one was #235, which means, I guess, that I had 234
| earlier versions that I've changed or deleted. The third shape in the text
| was numbered 264. I don't find anywhere in the properties of these shapes to
| assign them numbers manually, to make them show up in the right order. Is
| there any way to do this?
|
| You're being a great help, by the way. This problem has bedeviled me for
| years.
|
| Thanks
|
| RB
|
|
| "macropod" wrote:
|
| > Hi,
| >
| > To select the starting shape # and make the document scroll to and select each found shape as you go, you could use:
| >
| > Sub FindShapes()
| > Dim i As Integer
| > Dim Result As Integer
| > With ActiveDocument
| > If .Shapes.Count > 0 Then
| > For i = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
| > & vbCrLf & "Please Input the Shape # to start your search at."))) To .Shapes.Count
| > .Shapes(i).Select
| > Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
| > .Shapes(i).Select
| > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| > If Result = vbNo Then
| > Exit Sub
| > End If
| > Next
| > MsgBox "Finished."
| > End If
| > End With
| > End Sub
| >
| > I don't have any difficulty with the macro selecting shaps formatted with text wrapping set for "top and bottom".
| >
| > Cheers
| >
| > --
| > macropod
| > [MVP - Microsoft Word]
| >
| >
| > | Macropod, thanks.
| > |
| > | I copied and pasted the macro, and it works, sort of, but not quite the way
| > | I imagined. It finds pictures that are formatted as "tight" , but not those
| > | formatted with text wrapping set for "top and bottom." Also, when it finds a
| > | shape, it doesn't take me there. I have to say "no" to the dialogue, then use
| > | the "browse edits" tool to move to the selected picture. Then, when I run the
| > | macro again, it starts over at the top again, so I have to remember the
| > | sequence of pictures and keep saying "yes" until I reach the one I want to to
| > | look at. In other words, I almost have to know where they are so I can search
| > | for them. In the document I tried the macro on, for instance, the first
| > | picture was "235." After I used browse edits to reach 235, and ran the macro
| > | again, I said "yes" to 235, and "no" to 236, and then used browse edits to
| > | reach that. And so on. A bit cumbersome. Are there any other tweaks that
| > | might be written into the macro? I used to write lots of fancy macros in the
| > | the old wordperfect for DOS programs, but haven't done much but keystroke
| > | macros in Word, so I'm a bit rusty.
| > |
| > | Thanks
| > |
| > | RB
| > |
| > | "macropod" wrote:
| > |
| > | > Hi RB,
| > | >
| > | > You could use a macro like the following to go through the floating shapes.
| > | >
| > | > Sub FindShapes()
| > | > Dim i As Integer
| > | > Dim Result As Integer
| > | > With ActiveDocument
| > | > If .Shapes.Count > 0 Then
| > | > For i = 1 To .Shapes.Count
| > | > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| > | > If Result = vbNo Then
| > | > .Shapes(i).Select
| > | > Exit Sub
| > | > End If
| > | > Next
| > | > MsgBox "Finished."
| > | > End If
| > | > End With
| > | > End Sub
| > | >
| > | > As coded, if you tell the macro to stop searching before it's finished, it'll leave the last identified shape selected.
| > | >
| > | > Cheers
| > | >
| > | > --
| > | > macropod
| > | > [MVP - Microsoft Word]
| > | >
| > | >
| > | > | In Word 2000 and Word 2003, the "browse by" tool contains no provision for
| > | > | embedded pictures. (I use both versions.) I have some documents with various
| > | > | types of graphics and pictures: equations, imported bitmaps, imported jpegs.
| > | > | The "browse by graphic" finds equations, but not the others. I have
| > | > | determined that it will find them if I set the pictures to show "inline with
| > | > | text," but I need to format them in "tight" mode, or sometimes "In front of
| > | > | text," both options that put the picture on a different layer. At that point
| > | > | neither the browse tool nor the find function can locate them, because those
| > | > | tools only work on the text layer.
| > | > |
| > | > | Is there any way to change this, or write a macro to do what I want? When I
| > | > | used Wordperfect, I had no problem searching for any types of graphics. When
| > | > | I want to check the final formatting in Word, I have to hunt for them
| > | > | visually.
| > | > |
| > | > | RB
| > | >
| > | >
| > | >
| >
| >
| >
 
M

macropod

You're welcome. Now all you need to do to make it fly is to attach it to a toolbar button or a shortcut key-stroke combo.

Cheers

--
macropod
[MVP - Microsoft Word]


| Macropod,
|
| That did the trick. Perfect. I can't thank you enough.
|
| RB
|
| "macropod" wrote:
|
| > Hi RB,
| >
| > Yes, Word keeps track of the shapes according to the order in which they were inserted, not the page on which they appear, and
| > there's no re-numbering to take account of deleted shapes. The code I posted before processes the shapes in insertion order.
| >
| > Below you'll find a modified version of the code, which goes through the shapes in 'attached paragraph order'. With this
version,
| > the shape number you assign in the input box refers to the shape's relative position in the document. If there's more than one
shape
| > attached to a given paragraph, they're processed in insertion order. On exiting, you can even give the selected shape a
meaningful
| > name - if you like. If you don't want that functionality, comment out the line starting with 'oShp.Name = '.
| >
| > Sub FindShapes()
| > Dim oPara As Paragraph
| > Dim oShp As Shape
| > Dim i As Integer
| > Dim j As Integer
| > Dim Result As Integer
| > i = 0
| > j = 0
| > With ActiveDocument
| > If .Shapes.Count > 0 Then
| > j = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
| > & vbCrLf & "Please Input the Shape # to start your search at.")))
| > For Each oPara In .Paragraphs
| > If oPara.Range.ShapeRange.Count > 0 Then
| > For Each oShp In oPara.Range.ShapeRange
| > i = i + 1
| > If i >= j Then
| > oShp.Select
| > Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
| > oShp.Select
| > Result = MsgBox("Found Shape: " & oShp.Name & vbCrLf & "Continue Searching?", vbYesNo)
| > If Result = vbNo Then
| > oShp.Name = InputBox("Please give this shape (" & oShp.Name & vbCrLf & _
| > ") a meaningful name")
| > Exit Sub
| > End If
| > End If
| > Next oShp
| > End If
| > Next oPara
| > MsgBox "Finished."
| > End If
| > End With
| > End Sub
| >
| >
| > Cheers
| >
| > --
| > macropod
| > [MVP - Microsoft Word]
| >
| >
| > | Macropod,
| > |
| > | I tried it, and it works perfectly; but now I'm a little confused as to how
| > | these shapes are registered by Word. They don't show up in the order in which
| > | they occur in the document. They seem to come up in the order of creation or
| > | editing. So the first couple came in order, then the third one was skipped,
| > | and so on; but the ones that were skipped came later, as the macro made more
| > | passes. It is going by "shape no." How does Word assign shape numbers? In
| > | this case, the first one was #235, which means, I guess, that I had 234
| > | earlier versions that I've changed or deleted. The third shape in the text
| > | was numbered 264. I don't find anywhere in the properties of these shapes to
| > | assign them numbers manually, to make them show up in the right order. Is
| > | there any way to do this?
| > |
| > | You're being a great help, by the way. This problem has bedeviled me for
| > | years.
| > |
| > | Thanks
| > |
| > | RB
| > |
| > |
| > | "macropod" wrote:
| > |
| > | > Hi,
| > | >
| > | > To select the starting shape # and make the document scroll to and select each found shape as you go, you could use:
| > | >
| > | > Sub FindShapes()
| > | > Dim i As Integer
| > | > Dim Result As Integer
| > | > With ActiveDocument
| > | > If .Shapes.Count > 0 Then
| > | > For i = Abs(Int(InputBox("This document has " & .Shapes.Count & " floating Shapes." _
| > | > & vbCrLf & "Please Input the Shape # to start your search at."))) To .Shapes.Count
| > | > .Shapes(i).Select
| > | > Selection.GoTo What:=wdGoToPage, Name:=Selection.Information(wdActiveEndPageNumber)
| > | > .Shapes(i).Select
| > | > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| > | > If Result = vbNo Then
| > | > Exit Sub
| > | > End If
| > | > Next
| > | > MsgBox "Finished."
| > | > End If
| > | > End With
| > | > End Sub
| > | >
| > | > I don't have any difficulty with the macro selecting shaps formatted with text wrapping set for "top and bottom".
| > | >
| > | > Cheers
| > | >
| > | > --
| > | > macropod
| > | > [MVP - Microsoft Word]
| > | >
| > | >
| > | > | Macropod, thanks.
| > | > |
| > | > | I copied and pasted the macro, and it works, sort of, but not quite the way
| > | > | I imagined. It finds pictures that are formatted as "tight" , but not those
| > | > | formatted with text wrapping set for "top and bottom." Also, when it finds a
| > | > | shape, it doesn't take me there. I have to say "no" to the dialogue, then use
| > | > | the "browse edits" tool to move to the selected picture. Then, when I run the
| > | > | macro again, it starts over at the top again, so I have to remember the
| > | > | sequence of pictures and keep saying "yes" until I reach the one I want to to
| > | > | look at. In other words, I almost have to know where they are so I can search
| > | > | for them. In the document I tried the macro on, for instance, the first
| > | > | picture was "235." After I used browse edits to reach 235, and ran the macro
| > | > | again, I said "yes" to 235, and "no" to 236, and then used browse edits to
| > | > | reach that. And so on. A bit cumbersome. Are there any other tweaks that
| > | > | might be written into the macro? I used to write lots of fancy macros in the
| > | > | the old wordperfect for DOS programs, but haven't done much but keystroke
| > | > | macros in Word, so I'm a bit rusty.
| > | > |
| > | > | Thanks
| > | > |
| > | > | RB
| > | > |
| > | > | "macropod" wrote:
| > | > |
| > | > | > Hi RB,
| > | > | >
| > | > | > You could use a macro like the following to go through the floating shapes.
| > | > | >
| > | > | > Sub FindShapes()
| > | > | > Dim i As Integer
| > | > | > Dim Result As Integer
| > | > | > With ActiveDocument
| > | > | > If .Shapes.Count > 0 Then
| > | > | > For i = 1 To .Shapes.Count
| > | > | > Result = MsgBox("Found Shape: " & .Shapes(i).Name & vbCrLf & "Continue Searching?", vbYesNo)
| > | > | > If Result = vbNo Then
| > | > | > .Shapes(i).Select
| > | > | > Exit Sub
| > | > | > End If
| > | > | > Next
| > | > | > MsgBox "Finished."
| > | > | > End If
| > | > | > End With
| > | > | > End Sub
| > | > | >
| > | > | > As coded, if you tell the macro to stop searching before it's finished, it'll leave the last identified shape selected.
| > | > | >
| > | > | > Cheers
| > | > | >
| > | > | > --
| > | > | > macropod
| > | > | > [MVP - Microsoft Word]
| > | > | >
| > | > | >
| > | > | > | In Word 2000 and Word 2003, the "browse by" tool contains no provision for
| > | > | > | embedded pictures. (I use both versions.) I have some documents with various
| > | > | > | types of graphics and pictures: equations, imported bitmaps, imported jpegs.
| > | > | > | The "browse by graphic" finds equations, but not the others. I have
| > | > | > | determined that it will find them if I set the pictures to show "inline with
| > | > | > | text," but I need to format them in "tight" mode, or sometimes "In front of
| > | > | > | text," both options that put the picture on a different layer. At that point
| > | > | > | neither the browse tool nor the find function can locate them, because those
| > | > | > | tools only work on the text layer.
| > | > | > |
| > | > | > | Is there any way to change this, or write a macro to do what I want? When I
| > | > | > | used Wordperfect, I had no problem searching for any types of graphics. When
| > | > | > | I want to check the final formatting in Word, I have to hunt for them
| > | > | > | visually.
| > | > | > |
| > | > | > | RB
| > | > | >
| > | > | >
| > | > | >
| > | >
| > | >
| > | >
| >
| >
| >
 
S

stman

Hi,

I came across this macro you created and I think I might be able to use
parts of it. I'm trying to find all floating graphics and convert them to
inline. They are all anchored to the first character in a paragraph, so on
conversion they should shift over in place nicely. Then I'd add a space after
it with Selection.TypeText Text:=" "

The problem is that the method .Shapes(i).ConvertToInlineShape doesn't work.
I get a "bad parameter" error.

Can you offer any hints? Thanks.
 
S

stman

Aha! I found a way. Posted here for everyone's benefit:

For Each aField In ActiveDocument.Fields
If aField.Type = wdFieldRef Then
If InStr(aField.Code.Text, "\r ") <> 0 Then
aNewField = Replace(aField.Code.Text, "\r ", "", , , vbTextCompare)
aField.Code.Text = aNewField
aField.Update
End If
End If
Next aField
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top