finding all text boxes in document

T

Tony Logan

I'm using a macro to find all text boxes in a document. A behavior I've
witnessed that I can't explain is that rather than finding each text box
sequentially, the order in which the macro finds each text box appears
random. For instance, the macro never processes text box #1, then #2, then #3
and so on. Instead, the order is always something like: 15, 2, 3, 4, 11, 31,
and so on.

Just wondering if anyone has an explanation for why this would happen.

The code below is the portion of the macro that's supposed to find the text
boxes:

For Each myShp In ActiveDocument.Shapes
If myShp.Type = msoTextBox Then
i = i + 1
With myShp
myShp.Select
End With
myShp.ConvertToFrame
End If
Next
 
H

Helmut Weber

Hi Tony,

not a bug, a feature.

Try

For Each MyShp In ActiveDocument.Range.ShapeRange


Greetings from Bavaria, Germany

Helmut Weber, MVP, WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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