Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Automation keeps hanging when I intercept events?

Status
Not open for further replies.

Stat792

Programmer
Jan 7, 2004
12
0
0
US
I'm automating word and opening a document. I'm intercepting the word apps document save event and trying to insert my own code. Problem is that the app and word hang every time I do this.

BUT! If I set a break point in the event and just F8 through it then everything works just fine. It's almost like the issue is timing and my code is executing too fast or something.

Here's a sample:
Private Sub WordApp_ApplicationEvents2_Event_DocumentBeforeSave(ByVal Doc As Word.Document, ByRef SaveAsUI As Boolean, ByRef Cancel As Boolean) Handles WordApp.ApplicationEvents2_Event_DocumentBeforeSave

'Intercept the save attempt and reroute to the database

MsgBox("Caught you!")
Cancel = True

End Sub

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top