R
Remo
We use the event 'DocumentChange' to set the status of some symbols in
our symbol-bar. We found out that the event is fired every time when a
field (eg. Author-Field) or a table is inserted in the footer. That
means: If we enter 10 fileds in the footer, DocumentChange is fired 10
times. I think this is wrong. In this case the event should never be
fired.
Has anyone an idea how to prevent DocumentChange from beeing fired so
often? Is there a better Event to be used to set the status of symbols
enery time when the user changes to an other document, creates a new
document an so on?
Here is the code in the classmodule we use:
Public WithEvents App As Word.Application
'Handling the event "DocumentChange"
Private Sub App_DocumentChange()
Debug.Print "DocumentChange"
End Sub
'Handling the event "NewDocument"
'
'Every time a new document is created, we want to build a new footer
in this document.
'
Private Sub App_NewDocument(ByVal Doc As Document)
Debug.Print "NewDocument"
Dim Fusszeile As Range
Set Fusszeile = ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range
Debug.Print "Insert Feld"
ActiveDocument.Fields.Add Fusszeile, wdFieldCreateDate
Debug.Print "Insert Feld"
ActiveDocument.Fields.Add Fusszeile, wdFieldCreateDate
Debug.Print "Feld einfügen"
ActiveDocument.Fields.Add Fusszeile, wdFieldCreateDate
Debug.Print "Insert Feld"
End Sub
our symbol-bar. We found out that the event is fired every time when a
field (eg. Author-Field) or a table is inserted in the footer. That
means: If we enter 10 fileds in the footer, DocumentChange is fired 10
times. I think this is wrong. In this case the event should never be
fired.
Has anyone an idea how to prevent DocumentChange from beeing fired so
often? Is there a better Event to be used to set the status of symbols
enery time when the user changes to an other document, creates a new
document an so on?
Here is the code in the classmodule we use:
Public WithEvents App As Word.Application
'Handling the event "DocumentChange"
Private Sub App_DocumentChange()
Debug.Print "DocumentChange"
End Sub
'Handling the event "NewDocument"
'
'Every time a new document is created, we want to build a new footer
in this document.
'
Private Sub App_NewDocument(ByVal Doc As Document)
Debug.Print "NewDocument"
Dim Fusszeile As Range
Set Fusszeile = ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range
Debug.Print "Insert Feld"
ActiveDocument.Fields.Add Fusszeile, wdFieldCreateDate
Debug.Print "Insert Feld"
ActiveDocument.Fields.Add Fusszeile, wdFieldCreateDate
Debug.Print "Feld einfügen"
ActiveDocument.Fields.Add Fusszeile, wdFieldCreateDate
Debug.Print "Insert Feld"
End Sub