AW: aktuelle Seite für horizontalen Seitenumbruch
02.05.2009 12:25:10
Tino
Hallo,
habe auch mal etwas gebastelt, allerdings habe ich mir etwas von Beate abgekuckt. ;-)
Es werden die gleichen Seiten in die Zellen geschrieben, die auch im Seitenumbruch zu sehen sind.
Sub Test()
Dim LRow As Long, LCol As Long, LColT As Long, LPageRow As Long
Dim LCounter As Long, FindRow As Long, BreaksCount As Long
BreaksCount = ExecuteExcel4Macro("Get.Document(50)")
With ActiveSheet
If BreaksCount > 0 Then
On Error Resume Next
FindRow = .Cells.Find("*", , xlValues, 2, 1, 2, False, False).Row
FindRow = Application.Max(FindRow, .Cells.Find("*", , xlFormulas, 2, 1, 2).Row)
On Error GoTo 0
For LCol = 0 To .VPageBreaks.Count
If LCol = 0 Then
LColT = 1
Else
LColT = .VPageBreaks(LCol).Location.Column
End If
For LRow = 0 To .HPageBreaks.Count
If LRow = 0 Then
LPageRow = 1
Else
LPageRow = .HPageBreaks(LRow).Location.Row
End If
If FindRow >= LPageRow Then
LCounter = LCounter + 1
If LCounter > BreaksCount Then Exit For
.Cells(LPageRow, LColT) = "Seite " & LCounter & " von " & BreaksCount
End If
Next LRow
Next LCol
End If
End With
End Sub
Gruß Tino