I currently have a macro which does data mining and saves the workbook in the end. I intend to disable to the save function of the workbook and force the user to use the macro everytime the workbook needs to be saved. This is what I have so far but it does not seem to work. When I do this, my macro and this sub described below are both running in a loop. every time my macro tries to save the workbook, this sub is not allowing it. I basically want to force the user to use the macro to save the workbook.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim NoSave
NoSave = MsgBox("Changes have to be submitted before the workbook can be saved, Proceed and submit ?", vbYesNo, "Continue?")
If NoSave = vbNo Then
Cancel = True
Else
Main
End If
End Sub
Here is an Example. Paste this in
ThisWorkbook. This will not let you use theSaveor theSaveAs. You can however use the macroSaveThisFileto save the workbook. Please amend it to suit your needs.NOTE: If your Save macro is in a module then remove this
Dim SaveByCode As BooleanfromThisWorkbookand placePublic SaveByCode As Booleanin a module.