Shapes on which page?

B

Brad E.

Is there a way, using

For X = 1 to ActiveDocument.Shapes.Count
.....
Next X

to find out which page all my shapes are on? Either Word's perception of
pages or I have page numbers in the center footer would work.

I am exporting my findings to Excel, so I just need to know the coding to
pull some kind of identifier for where it is in the document.
 
J

Jay Freedman

Try something like this:

Sub x()
Dim i As Long
Dim sDoc As Document, dDoc As Document
Dim Shp As Shape

Set sDoc = ActiveDocument
Set dDoc = Documents.Add

For Each Shp In sDoc.Shapes
dDoc.Range.InsertAfter _
Shp.Anchor.Information(wdActiveEndAdjustedPageNumber) _
& vbCr
Next
End Sub

You may instead want to use wdActiveEndPageNumber, which gives the
"real" page number ignoring any restarts.

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

Brad E.

Thanks, Jay.

I actually concatenated the section and adjusted page number:

....Shp.Anchor.Information(wdActiveEndSectionNumber) & " -- " & _
Shp.Anchor.Information(wdActiveEndAdjustedPageNumber)

Brad
 

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