Hi DC
Wie gesagt muss es sich um Inlineshapes handeln, die mit Text in Zeile platziert sind. Sobald du Bilder im Text frei platzierst (z.B. Passend), musst du zusätzlich die Shapes-Auflistung durchlaufen. Probiers nochmal so:
Sub Bildseiten_Zaehlen()
Dim ishp As InlineShape, shp As Shape, ftn As Footnote
Dim pgn As Long, oldpgn As Long, pgc As Long, pgcf As Long, gezaehlt As String, gezaehltf As String
For Each ishp In ActiveDocument.InlineShapes
oldpgn = pgn
pgn = ishp.Range.Information(wdActiveEndPageNumber)
If pgn > oldpgn Then
gezaehlt = gezaehlt & pgn & ";"
pgc = pgc + 1
If ishp.PictureFormat.ColorType = msoPictureAutomatic Then
gezaehltf = gezaehltf & pgn & ";"
pgcf = pgcf + 1
End If
End If
Next ishp
pgn = 0
For Each shp In ActiveDocument.Shapes
oldpgn = pgn
pgn = shp.Anchor.Information(wdActiveEndPageNumber)
If pgn > oldpgn And InStr(1, gezaehlt, pgn) = 0 Then
gezaehlt = gezaehlt & pgn & ";"
pgc = pgc + 1
End If
If pgn > oldpgn And shp.PictureFormat.ColorType = msoPictureAutomatic And InStr(1, gezaehltf, pgn) = 0 Then
gezaehltf = gezaehltf & pgn & ";"
pgcf = pgcf + 1
End If
Next shp
pgn = 0
For Each ftn In ActiveDocument.Footnotes
For Each ishp In ftn.Range.InlineShapes
oldpgn = pgn
pgn = ishp.Range.Information(wdActiveEndPageNumber)
If pgn > oldpgn And InStr(1, gezaehlt, pgn) = 0 Then
gezaehlt = gezaehlt & pgn & ";"
pgc = pgc + 1
End If
If pgn > oldpgn And ishp.PictureFormat.ColorType = msoPictureAutomatic And InStr(1, gezaehltf, pgn) = 0 Then
gezaehltf = gezaehltf & pgn & ";"
pgcf = pgcf + 1
End If
Next ishp
Next ftn
MsgBox "Seiten mit Bildern: " & pgc _
& Chr(13) & "Seiten mit farbigen Bildern: " & pgcf
End Sub
Damit habe wir nun schon drei Schleifen die durchlaufen werden müssen. Aber eine andere Möglichkeit sehe ich nicht, schnell und effizient die Seitennummern der Bilder zu ermitteln. Ein freies Platzieren von Bildern in Fußnoten ist zumindest in meiner Word-Version nicht möglich. Daher habe ich auf die vierte Schleife verzichtet. Wieso also Bilder in Fußnoten nicht erkannt werden, kann ich dir nicht sagen da ich dein Dokument nicht kenne. Aber das kann eigentlich nicht sein. Denn alle Bilder sind entweder ein Shape oder ein Inlineshape.
Gruß Mr. K.
|