Results 1 to 9 of 9

Thread: [RESOLVED] Object Varialbe or With Block Not Set

Threaded View

  1. #6

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Object Varialbe or With Block Not Set

    Thanks for responses to date:

    techgnome:

    if the user "closes" Excel, there is no longer an ActiveWorkbook.
    As you aptly point out it appears when user is closing Excel directly, the ActiveWorkbook is closed (by Excel I assume) and consequently the reference (in VB) is no longer valid (left hanging).
    Excel is still running in the background (I assume because of COM), hence the oxlApp VB object reference is still active.
    Using "On Error Resume Next" allows the code to bypass the ActiveWorkbook reference and excecute oxlApp.Quit, which shuts down Excel from the VB App
    and does not generate the Error (call to my routine).

    Other than "ON ERROR Resume Next" any other work around ?

    ///////////// UPDATE //////////////////////

    Modifying Bonnie West's post (Thanks Bonnie), the following code worked

    Code:
             If Not oxlApp.ActiveWorkbook Is Nothing Then oxlApp.ActiveWorkbook.Close False
    Last edited by dw85745; Jan 3rd, 2013 at 12:42 PM. Reason: Update

Posting Permissions

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



Click Here to Expand Forum to Full Width