Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problems closing Excel correctly by code
Dear All,
W2000 Office2000 Access-application that manages quotations (= excel-files) In a sub I change some values in an excel-file and close like this (see code-end below) ....... xlApp.Visible = False ........ Set WS = Nothing WB.Close SaveChanges:=True Set WB = Nothing xlApp.Quit Set xlApp = Nothing Exit sub This workes OK, BUT while re-opening this file or another I test if Excel is running to prevent that several quotations are open at the same time. Although there is no excel-file active the function IsExcelRunningNow() returns TRUE Where is the mistake? THANKSł, Filip Function IsExcelRunningNow() As Boolean Dim MyXL As Object ' Variable to hold reference to Microsoft Excel. On Error Resume Next ' Defer error trapping. IsExcelRunningNow = True Set MyXL = GetObject(, "Excel.Application") If Err.Number < 0 Then IsExcelRunningNow = False Err.Clear ' Clear Err object in case error occurred. Set MyXL = Nothing ' Release reference to the application and spreadsheet. End Function |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problems closing Excel correctly by code
Pls check if excel is running in the background invisibly.
Use MyXL.UserControl = false before you quit BTW read up on the GetObject, since with excel allows the following: Dim wb as Object Set wb = Getobject("c:\Myfile.xls") you could directly test if a quotation is open by connect to that quotation. Dm Unseen |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problems closing Excel correctly by code
Thanks,
BUT no change Finally the problem was soved by changing my code ActiveSheet WS WS.Unprotect (varPassWord) WS.Cells(2, 2) = "Basisofferte" & "=" & strBasisNaam WS.Protect (varPassWord) Thanks "DM Unseen" wrote in message oups.com... Pls check if excel is running in the background invisibly. Use MyXL.UserControl = false before you quit BTW read up on the GetObject, since with excel allows the following: Dim wb as Object Set wb = Getobject("c:\Myfile.xls") you could directly test if a quotation is open by connect to that quotation. Dm Unseen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problems merging an excel file due to code or file problems? | Excel Programming | |||
problems closing excel | Excel Programming | |||
Problems closing a workbook with VBA | Excel Programming | |||
problems closing workbook | Excel Programming | |||
Excel code to Wait until Word finishes printing before closing | Excel Programming |