Get page number of OLE Object

J

Jason Morin

Hello. I use the following code to generate a text file that lists all
embedded OLE objects in a doc. How do I find the page number where each OLE
object is embedded? Thanks.

********

Sub ListFiles()

Dim shape As InlineShape
Dim sFile As String
Dim nFileNum As Long
Dim sWarning As String

sWarning = "Note: If you are using Word 97 of 2000, " & _
"this macro will not work on files created in Word " & _
"2003 or later!"

MsgBox sWarning, vbExclamation

nFileNum = FreeFile
Open "Embedded_Files.txt " For Output As #nFileNum

For Each shape In ThisDocument.InlineShapes
If shape.Type = wdInlineShapeEmbeddedOLEObject Then
sFile = shape.OLEFormat.IconLabel
Print #nFileNum, sFile
sFile = Empty
End If
Next shape

Print #nFileNum, "---------------"
Print #nFileNum, "Total Files: " & ThisDocument.InlineShapes.Count

Close #nFileNum

End Sub
 
H

Helmut Weber

Hi Jason,

Sub Test699()
Dim shape As InlineShape
For Each shape In ActiveDocument.InlineShapes
If shape.Type = wdInlineShapeEmbeddedOLEObject Then
MsgBox shape.Range.Information(wdActiveEndPageNumber)
End If
Next shape
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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

Similar Threads

AddPicturesToShapes 0
Automated " delimiter adder? 1
Convert Excel file to Txt file 4
Double quote delimiter script 0
Comma Delimited Export 2
VBA Export to PDF 0
loop through (should be easy) 0
Excel to txt 2

Top