Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application.Quit 'event'

Status
Not open for further replies.

kutz13

IS-IT--Management
Feb 24, 2004
62
GB
I'm hoping someone out there can help. I have an Excel workbook (2002) which runs many queries & procedures against remote ADODB connections using VBA. Using the 'Workbook_BeforeClose' event I'm able to remove sensitive data & save prior to closure. On the user quitting the app, instead of just the workbook, I have the same result however this is proceeded by a runtime error '5' dialogue box. Is there a way for Excel to see the 'app quit' as an event, or remove said dialogue box? Any help appreciated.
 
If this error is linked with other workbooks, you can extend control to other workbooks, for instance (ThisWorkbook module):
Code:
Public WithEvents xlApp As Excel.Application

Private Sub Workbook_Open()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
If MsgBox("You try to close: " & Wb.Name & vbCrLf & "Continue?", vbCritical + vbYesNo, "Workbook action") = vbNo Then
    Cancel = True
End If
End Sub

combo
 
No, the error is generated on a standalone workbook being closed via the application.quit event. The code set to run at workbook close still runs sucessfully, it's just that the error dialogue confuses users and I'd like to suppress it if possible.
 
Do you have any add-ins involved in the data processing? Can you post the part of code that causes problems?

combo
 
Thanks Combo for highlighting 'Add-ins', I removed all except the ODBC add-in and everythings doing what I expected!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top