C
christophercbrewster via OfficeKB.com
I have a routine that runs automatically on save. I was working on something
that seems unrelated, but the auto-run no longer worked. The related code
wasn't changed. I'd appreciate if anyone can identify anything that could
affect this. (Word 2003 with XP.)
___________________________________
In main module (only the relevant code is shown):
-------------------------------------
Public eSaveEvent As New cUpdateClass
-------------------------------------
Sub AutoExec()
....
' eSaveEvent object is an instance of the cUpdateClass class.
Set eSaveEvent.appWord = Word.Application
End Sub
___________________________________
In Class cUpdateClass:
-------------------------------
Public WithEvents appWord As Word.Application
-------------------------------
Private Sub appWord_DocumentBeforeSave _
(ByVal Doc As Document, _
SaveAsUI As Boolean, _
Cancel As Boolean)
On Error Resume Next ' Test to see if this docvariable is set
spptnm = ActiveDocument.Variables("file-to-read").Value
If Err = 0 Then ' If no error, do update step
appWord.Run "UpdateSlideReferences"
End If
End Sub
--------------------------------------------------------
Private Sub Class_Initialize()
Set appWord = Word.Application
End Sub
--
Christopher Brewster
Lockheed Martin, Eagan MN
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200902/1
that seems unrelated, but the auto-run no longer worked. The related code
wasn't changed. I'd appreciate if anyone can identify anything that could
affect this. (Word 2003 with XP.)
___________________________________
In main module (only the relevant code is shown):
-------------------------------------
Public eSaveEvent As New cUpdateClass
-------------------------------------
Sub AutoExec()
....
' eSaveEvent object is an instance of the cUpdateClass class.
Set eSaveEvent.appWord = Word.Application
End Sub
___________________________________
In Class cUpdateClass:
-------------------------------
Public WithEvents appWord As Word.Application
-------------------------------
Private Sub appWord_DocumentBeforeSave _
(ByVal Doc As Document, _
SaveAsUI As Boolean, _
Cancel As Boolean)
On Error Resume Next ' Test to see if this docvariable is set
spptnm = ActiveDocument.Variables("file-to-read").Value
If Err = 0 Then ' If no error, do update step
appWord.Run "UpdateSlideReferences"
End If
End Sub
--------------------------------------------------------
Private Sub Class_Initialize()
Set appWord = Word.Application
End Sub
--
Christopher Brewster
Lockheed Martin, Eagan MN
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200902/1