[AccessD] Excel Automation Question

Rocky Smolin rockysmolin at bchacc.com
Thu Aug 25 15:56:45 CDT 2016


Not hard to check if the app is open:

Function IsExcelRunning() As Boolean
Dim xlApp As Excel.Application
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
IsExcelRunning = (Err.Number = 0)
Set xlApp = Nothing
Err.Clear
End Function

Returns true/false


Problem is I see more and more users who have one or more spreadsheets open
all day. So I'd probably better not close just any instance of Excel. :)

I wish there was a way to open the spreadsheet 'modal' so the code would
stop after the open and when the sheet closed the code would carry on and I
could delete the instance of Excel that was opened for the spreadsheet.

Rocky


-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Paul Hartland
Sent: Thursday, August 25, 2016 1:45 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Excel Automation Question

Rocky

Just off hand there is some code that checks if an application is open, I
haven't got this to hand but sure a google search will find some, when the
user returns to the access app could you not run the function to check if an
instance of Excel is open and if so then close it from Access, obviously a
problem with this is if the user returns to the Access app and still wants
the Excel sheet open, but just a thought.

Paul

On 25 August 2016 at 20:55, Rocky Smolin <rockysmolin at bchacc.com> wrote:

> Dear List:
>
>
>
> I want to open a spreadsheet from Access and am using:
>
>
>
>     Set objXLApp = New Excel.Application
>
>     objXLApp.Workbooks.Open gstrBackEndPath & "\PO_" &
> Me.cboPOList.Column(1) & ".xlsx"
>
>     objXLApp.Visible = True
>
>
>
> which works just fine.  However, when the spreadsheet is closed by the 
> user the instance of Excel remains - I can see it in the Task Manager.
>
>
>
> If I close the spreadsheet from Access:
>
>
>
>     objXLApp.ActiveWorkbook.Save
>
>     objXLApp.ActiveWorkbook.Close True
>
>     objXLApp.Quit
>
>     Set objXLApp = Nothing
>
>
>
> Of course, Excel goes away.
>
>
>
> Is there a technique for closing that instance of access when the user 
> closes a spreadsheet opened by an access program?
>
>
>
> MTIA
>
>
>
>
>
> Rocky Smolin
>
> Beach Access Software
>
> 760-683-5777
>
>  <http://www.bchacc.com> www.bchacc.com
>
>  <http://www.e-z-mrp.com> www.e-z-mrp.com
>
> Skype: rocky.smolin
>
>
>
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



--
Paul Hartland
paul.hartland at googlemail.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list