I would like to retrieve the number of the page a picture is on. I know how to retrieve the picture using
ActiveDocument.Range.ShapeRange.LinkFormat.SourceFullName
but what variable holds the pagenumber of a picture?
I would like to retrieve the number of the page a picture is on. I know how to retrieve the picture using
ActiveDocument.Range.ShapeRange.LinkFormat.SourceFullName
but what variable holds the pagenumber of a picture?
https://word.tips.net/T000728_Determining_the_Current_Page_Number.html
CurPage = Selection.Information(wdActiveEndAdjustedPageNumber)
CurPage = Selection.Information(wdActiveEndPageNumber)
How about this?
Maybe you could change it to:
ActiveDocument.Range.ShapeRange.Information(wdActiveEndAdjustedPageNumber)
ActiveDocument.Range.ShapeRange.Information(wdActiveEndPageNumber)
Not tested as on a Linux machine right now!!
The following code will create a list of pictures including the page it is located on.
... Sub LoopPages() With ActiveDocument Dim numPages As Integer: numPages = .Content.ComputeStatistics(wdStatisticPages) Dim actPage As Integer Dim rng As Range
Dim num As Integer
Dim FileOut As String: FileOut = "c:\Temp\Images\Pages.txt"
Open FileOut For Output As #1
For actPage = 1 To numPages
' Create a range of Page actPage
Set rng = .GoTo(What:=wdGoToPage, Name:=actPage)
Set rng = rng.GoTo(What:=wdGoToBookmark, Name:="\page")
For Each Shp In rng.ShapeRange
With Shp
If (.Type = msoLinkedPicture) Then
num = num + 1
Print #1, Format(num, "000") & " --> Page= " & actPage & " --> " & .LinkFormat.SourceFullName
End If
End With
Next Shp
For Each Shp In rng.InlineShapes
With Shp
If (.Type = wdInlineShapeLinkedPicture) Then
num = num + 1
Print #1, Format(num, "000") & " --> Page= " & actPage & " --> " & .LinkFormat.SourceFullName
End If
End With
Next Shp
Next actPage
MsgBox num
Close #1
End With
End Sub ...