I have a spreadsheet that has several combo boxes on it with code for the "change" event. Everything works fine when they are used. In addition, I have some code that fires on the workbook's "beforeclose" event, but it is not related at all to the "change" events on the combo boxes. My problem is this: when I close the workbook by clicking on the "x" for the workbook (not the highest one for the Excel application) or I choose "close" from the File menu, I don't have any problems. However, if I click on the "x" for the Excel application (the one at the very top right), I get a run-time error of two types:
01) Method Sheets of object _Global failed
---- or ----
02) Object variable or With Block variable not set
What gives? Especially since the highlighted portion of code has nothing to do with the instructions in the "BeforeClose" event of the workbook. Here's the code I am using:
#### This is what's highlighted as an error ####
#### Placed in the Volume_Report worksheet ####
Private Sub cboAE_Change()
Sheets("XML_Data".Range("F2" = cboAE.Value
End Sub
#### This is the code run on the workbook close ####
#### Placed in the "ThisWorkbook" area ####
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Volume_Report".cmdCreateXML = True
End Sub
Why would this happen?
01) Method Sheets of object _Global failed
---- or ----
02) Object variable or With Block variable not set
What gives? Especially since the highlighted portion of code has nothing to do with the instructions in the "BeforeClose" event of the workbook. Here's the code I am using:
#### This is what's highlighted as an error ####
#### Placed in the Volume_Report worksheet ####
Private Sub cboAE_Change()
Sheets("XML_Data".Range("F2" = cboAE.Value
End Sub
#### This is the code run on the workbook close ####
#### Placed in the "ThisWorkbook" area ####
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Volume_Report".cmdCreateXML = True
End Sub
Why would this happen?