Consulting

Results 1 to 3 of 3

Thread: unhiding word application on error

  1. #1
    VBAX Contributor
    Joined
    Jun 2004
    Location
    Texas
    Posts
    139
    Location

    SOLVED - unhiding word application on error

    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!
    With program specs this fickle, you've just got to believe in Discord.

  2. #2
    VBAX Contributor
    Joined
    Jun 2004
    Location
    Texas
    Posts
    139
    Location

    never mind

    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:
    [VBA]
    If acbIsAppLoaded("OpusApp") Then
    Word.Application.Visible = True
    Word.Application.Quit
    End If
    [/VBA]

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

    Thanks anyway!
    With program specs this fickle, you've just got to believe in Discord.

  3. #3
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Excellent, eed. I'll mark this solved. Thanks for sharing the answer with us!
    ~Anne Troy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •