Why would auto-run on save suddenly fail?

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
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
 
C

christophercbrewster via OfficeKB.com

I seem to have a solution to this. I had previously closed Word and reopened,
thinking it would re-run Auto_Exec, but I started to question whether it
really did. I tried closing the toolbar that Auto_Exec creates and explicitly
re-running it. This worked. I'm not sure why this did the trick, but anyway
it worked.

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200902/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top