Can't close open hidden workbook (1 Viewer)

llkhoutx

Registered User.
Local time
Today, 04:30
Joined
Feb 26, 2001
Messages
4,018
I using Access 2010 (Enterprise) on Windows 7 Enterprise PC. In the course of executing VBA code, I open an Excel workbook in Access using
PHP:
    Dim xlAPP As Excel.Application
    Dim wKb As Excel.Workbook
    Dim sNewxlsx = {a valid path and "xlsx" file}
    Set xlAPP = New Excel.Application
    xlAPP.Visible = True
    Set wKb = Workbooks.Open(FileName:=sNewxlsx, ReadOnly:=False)
    {various machinations and calculations on the wKb}

In making changes to the Access program, it occasionally crashes and I close the above wKb. Sometimes, on a crash, I manually close the wKb.

My issue is when I don't have to opportunity to close the subject wKb, manually or programmically, AND on opening a new instance of the Access program I am unable to open the subject workbook file for changes; the wKb is hidden and is open. I can't close the wKb programmatically. I can't "see" the wKb when "checking" open workbooks. To presently cure the problem, I have to re-boot.

Question: How can I close the "hidden & open" wKb, without saving the changes, which I cannot "see" in Access. :banghead:

Of course, fix all program errors so that it doesn't crash. :mad:

Thank you in advance for your insight and suggestions.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:30
Joined
May 7, 2009
Messages
19,232
use the excel application object to open the workbook.
instead of:

Set wKb = Workbooks.Open(FileName:=sNewxlsx, ReadOnly:=False)

use:

Set wKb = xlApp.Workbooks.Open(FileName:=sNewxlsx, ReadOnly:=False)

when your done with the workbook, close without saving.

wKb.Close False
set wKb = Nothing
 

llkhoutx

Registered User.
Local time
Today, 04:30
Joined
Feb 26, 2001
Messages
4,018
Thank you, I'll give you suggestion a try.
 

Users who are viewing this thread

Top Bottom