Hi. I put together a macro that watches the document changes like adding a page. However the macro does not detect a page addition when using the Layout view and CTRL+left click drag. Why is that?
Here is the code located in the 'ThisMacroStorage' section. What am I missing?
Dim WithEvents CurDoc As Document Private Sub GlobalMacroStorage_WindowActivate(ByVal Doc As Document, ByVal Window As Window) Set CurDoc = Doc End Sub Private Sub GlobalMacroStorage_WindowDeactivate(ByVal Doc As Document, ByVal Window As Window) Set CurDoc = Nothing End Sub Private Sub CurDoc_PageCreate(ByVal Page As Page) update End Sub Private Sub CurDoc_PageDelete(ByVal Count As Long) update End Sub
I don't know that your missing anything; it may just be the way that it (doesn't) work.
"Insert Page After" and "Insert Page Before" do fire that event, but "Duplicate Page" does not.
Why? I dunno.
try use CurDoc_PageChange or CurDoc_PageActivate and check CurDoc.Pages.Count
Is this the correct way to write this out?
Private Sub CurDoc_PageChange(ByVal Page As Page)check CurDoc.Pages.Count updateEnd Sub
Private Sub GlobalMacroStorage_WindowActivate(ByVal Doc As Document, ByVal Window As Window)
Set CurDoc = Doc: TotalPages = CurDoc.Pages.Count
End Sub
Private Sub CurDoc_PageChange(ByVal Page As Page) if CurDoc.Pages.Count > TotalPages then 'page added
TotalPages = CurDoc.Pages.Count update
end ifEnd Sub