Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / April 2008

Tip: Looking for answers? Try searching our database.

Excel Application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin - 29 Apr 2008 15:18 GMT
I have the following code in Access that is used to open an Excel file, do
some work with that file, then close the file and the Excel application.  

   Dim xlApp As Excel.Application
   Set xlApp = CreateObject("Excel.Application")

   xlApp.Workbooks.Open FileName:=HRFileName
   With xlApp

    [Work with the Excel file]

       'Close HR File
       .Workbooks(HRFile).Close False

   End With

   ' Close Excel with the Quit method on the Application object.
   xlApp.Quit
   ' Release the object variable.
   Set xlApp = Nothing

Everything works fine except that after the script is completed, the Excel
application is open in the Windows Taskbar with the spreadsheet open in
Read-only mode.  

Can someone offer some directioin as to how to stop this?  It is annoying
for the end-user to have to close Excel after this script is done.

Thanks.
Klatuu - 29 Apr 2008 15:41 GMT
As posted, the code appears to be correct.  The problem most likely exists in
the unposted code.

The most usual cause of the Excel app not closing is an incorrect or
incomplete object reference.  When using Automation it is critical to fully
qualify all your object references.  If Access can't determine an Automation
ojbect reference, it will create another Excel Application object on its own
and use that.  So when you Quit, you quit one, but not the other.

Check all your object references to be sure every object created refers all
the way back to the original Excel Application object.
Signature

Dave Hargis, Microsoft Access MVP

> I have the following code in Access that is used to open an Excel file, do
> some work with that file, then close the file and the Excel application.  
[quoted text clipped - 25 lines]
>
> Thanks.
Martin - 29 Apr 2008 16:09 GMT
Thanks for the reply.  I will dig back thru the references.

> As posted, the code appears to be correct.  The problem most likely exists in
> the unposted code.
[quoted text clipped - 37 lines]
> >
> > Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.