select next graphic

P

Patricia Shannon

I hate to bother you with such a simple question, but I haven't been able to
get it to work.
I am trying to write a macro (so I can assign it to a key or button) that
will go to the next graphic and select it. Then I can execute another macro
I have written that copies it to Paint, reverses colors, and copies it back.
(If I can get the graphic selection working, I'll incorporate it into my main
macro.)

I can go to the next graphic, but I haven't been able to select it.
I used
Selection.GoToNext(wdGoToGraphic)
and when that didn't select the graphic, I tried
Selection.GoToNext(wdGoToGraphic).Select
but that didn't do anything different.
I've looked at help, and in this forum, but haven't been able to figure out
how to select the graphic.

Thank you
 
J

Jezebel

You don't need a macro for this. Click the 'Select browse object' button
(the little circle between the double arrows at the bottom of the vertical
scroll bar), and select graphic as the browse object. Then use the double
arrows.
 
P

Patricia Shannon

Thank you. That is what I'm doing now to get to the graphic. But it doesn't
select the graphic. I have to click on the graphic before I run my macro.
If I could do the goto and select in VBA, I could incorporate it into my
macro and do everything in one click, instead of 3. I have a lot of these
screen prints to process.
 
J

Jay Freedman

Try using this code in your macro:

Dim oRgStart As Range
Dim oRgNext As Range

Set oRgStart = Selection.Range
Set oRgNext = Selection.GoTo(what:=wdGoToGraphic, _
which:=wdGoToNext)
If Not oRgNext.IsEqual(oRgStart) Then
Selection.MoveEnd unit:=wdCharacter, Count:=1
End If

The reason for using the ranges is that if there is no "next" graphic,
the selection doesn't move, and you don't want to extend the selection
by another character.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
P

Patricia Shannon

Thank you very much Jay. When I was looking at the documentation for things
like MoveEnd, I didn't realize that the wdcharacter would work on a graphic.
 

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