Heenan, Lambert
Lambert.Heenan at AIG.com
Fri Jun 13 16:13:13 CDT 2008
Quitting Excel. This is how I do it... Sub Excel_CloseWorkBook(xlApp As Excel.Application, Optional bSaveChanges As Boolean = False) Dim wb As Excel.Workbook On Error Resume Next If xlApp.Name > "" Then ' reference a property to see if we get an error End If If Err.Number <> 0 Then Exit Sub ' already closed On Error GoTo 0 For Each wb In xlApp.Workbooks 'Close all open workbooks wb.Close bSaveChanges Next wb xlApp.UserControl = False Set xlApp = Nothing End Sub The crucial statement is "xlApp.UserControl = False ". Leave it out and Excel will not shut down. In use it's a case of setting all your references to worksheets to nothing and then call Excel_CloseWorkBook objExlApp, [True|False] HTH - works for me. :-) Lambert -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hewson, Jim Sent: Friday, June 13, 2008 3:54 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Hide datasheet view of table when appending I've used a Recordset before, I didn't think about using it. I have the TransferSpreadsheet working as Lambert suggested and everything is working. My only problem now is that Excel won't shut down even though I tell it to quit and set the reference to nothing. Thanks everyone for your help. Jim jhewson at nciinc.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka Sent: Friday, June 13, 2008 2:48 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Hide datasheet view of table when appending The difference is control, without opening Excel. Have you ever used a recordset in code? With ADO, you can open an excel spreadsheet as a recordset. Don't even have to have Excel installed on the machine. Drew ############################################################################ #### This email transmission contains information from NCI Information Systems, Inc. that may be considered privileged or confidential and is intended solely for the named recipient. If you have received this message in error, please contact the sender immediately and be aware that the use, copying or dissemination of this information is prohibited. ############################################################################ #### -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com