tony.reynolds
Board Regular
- Joined
- Jul 8, 2010
- Messages
- 97
I have a workbook called orders.xlsm. it operates entirely from userform so therfore i have the workbook hidden and the user can only see the userform.
on the close of the userform the code is as bleow.
The only trouble i have is if i have another workbook open when I open Orders.xlsm it is still open in the same instance. so when this code is called the excell try to quit and if the other workbook is not saved it askes if you want to save before closing.
I would like to check
Please anyone let me know if this can be done.
on the close of the userform the code is as bleow.
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
If Not NewOrderSupplier = Empty Then
Dim Msg, Style, Title, Response
Msg = "It looks like you have started an order." & Chr(10) & "Do you want to cancel this order?"
Style = vbYesNo + vbQuestion + vbDefaultButton2
Title = "OrderStocker"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
GoTo CloseWB
Else
Cancel = True
Exit Sub
End If
End If
CloseWB:
Unload Me
ActiveWorkbook.Save
Application.Visible = True
Application.Quit
End If
End Sub
I would like to check
Code:
if
Orders .xlsm is the only workbook open then
Workbooks("Orders.xlsm").Save
Application.Visible = True
Application.Quit
else
Workbooks("Orders.xlsm").Save
Application.Visible = True
Workbooks("Orders.xlsm").Close
Please anyone let me know if this can be done.
Last edited: