Thank you HansV
I found that by using this code at the beginning
Code: Select all
Application.Dialogs(xlDialogSaveAs).Show arg2:=xlOpenXMLWorkbookMacroEnabled
when a new report is about to start, it would help in preserving the original and make it less confusing to the user about how and when to name and save a report. This is completed at the very first step.
What I noticed was the way the code seems to work, when I select the “Start new report†command button that then runs
Code: Select all
Application.Dialogs(xlDialogSaveAs).Show arg2:=xlOpenXMLWorkbookMacroEnabled
It then opens the Save as dialog I would then name the workbook and select location and then save, from there it seems to close the original and leave the save as copy opened in same location.
And now referring to the other code
Code: Select all
Dim Answer As String
Dim MyNote As String
'Place your opening text here
MyNote = "You are now closing, You have the option to save changes by selecting YES or select NO to close only !"
'Display MessageBox
Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "???")
If Answer = vbNo Then
'Code for No button Press
MsgBox "Report has not be saved - Close only!"
ThisWorkbook.Close savechanges:=False ‘I changed Active to This on this line
ThisWorkbook.Close
Else
'Code for Yes button Press
MsgBox "Report has now been saved!"
If ThisWorkbook.Saved = False Then
ThisWorkbook.Save
ThisWorkbook.Close
End If
End If
With a command button labeled "Close" this code is used to save the workbook as the user goes along, starting and stopping or for whatever reason. Since it is now a xlsm and not a xltm it came now be saved.
The issue or concern I was referring to was when the original / Master xlsm workbook is first open, and just for whatever reason the user were to close and try to save using this code and then opt out an error message would then arise. I was hoping to be able to add something to this code that if error would arrise, would stop code.