PDA

View Full Version : unhiding word application on error



eed
08-09-2004, 11:20 AM
Okay, so my code is busily manipulating a document in Word, using objects wrdApp and wrdDoc. I don't want my user to have to stare at all the funny, busy screen activity, so I have wrdApp.Visible set to False. At the end of my procedure, I change wrdApp.Visible to True so the user can see the finished document.

The problem I'm having is this: say a user presses Cancel when my query asks for a parameter. I need to handle that error. One thing I need to handle is the fact that my procedure may have already opened one or more documents, but Word is hidden. I want to unhide Word if an error occurs so the user isn't running something hidden without knowing it.

I tried simply adding wrdApp.Visible = True into my error-handler, but I keep getting a compile error (block "with" without "end if"). Can anyone explain to me how to unhide an application on an error?

Thanks in advance for your help!

eed
08-09-2004, 12:09 PM
Okay, never mind, I got it.

My approach was to ditch the use of my object variable and add this to my error-handler code:

If acbIsAppLoaded("OpusApp") Then
Word.Application.Visible = True
Word.Application.Quit
End If


(BTW, the function acbIsAppLoaded comes from the Access Cookbook by Ken Getz, Paul Litwin, and Andy Baron).

Thanks anyway!

Anne Troy
08-09-2004, 12:35 PM
Excellent, eed. I'll mark this solved. :) Thanks for sharing the answer with us!