Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Macro Before Save
Is there a way to run a macro each time before you hit the save button.
Meaning if you go to file - save - it runs the macro instead of saving the file or if you hit control +s it runs the macro instead of saving the file Let me know thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Macro Before Save
Check out the BeforeSave Event under the "ThisWorkbook" in MicroSoft
Excel Objects in the VBA Editor Die_Another_Day RigasMinho wrote: Is there a way to run a macro each time before you hit the save button. Meaning if you go to file - save - it runs the macro instead of saving the file or if you hit control +s it runs the macro instead of saving the file Let me know thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Macro Before Save
I found this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) a = MsgBox("Do you really want to save the workbook?", vbYesNo) If a = vbNo Then Cancel = True End Sub Where would I put this code? In the general part of the workbook? Die_Another_Day wrote: Check out the BeforeSave Event under the "ThisWorkbook" in MicroSoft Excel Objects in the VBA Editor Die_Another_Day RigasMinho wrote: Is there a way to run a macro each time before you hit the save button. Meaning if you go to file - save - it runs the macro instead of saving the file or if you hit control +s it runs the macro instead of saving the file Let me know thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Macro Before Save
No. in the "Project" Explorer you will see VBAProject(YourWorkbook.xls)
Expand that. Now you should see Microsoft Excel Objects Expand that Now there should be a "This Workbook" item double click that That should open a code window with 2 comboboxes at the top in the left combobox select "Workbook" in the right combobox select "BeforeSave" Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) End Sub Those 2 lines should appear for you. Paste the other lines in between Die_Another_Day RigasMinho wrote: I found this: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) a = MsgBox("Do you really want to save the workbook?", vbYesNo) If a = vbNo Then Cancel = True End Sub Where would I put this code? In the general part of the workbook? Die_Another_Day wrote: Check out the BeforeSave Event under the "ThisWorkbook" in MicroSoft Excel Objects in the VBA Editor Die_Another_Day RigasMinho wrote: Is there a way to run a macro each time before you hit the save button. Meaning if you go to file - save - it runs the macro instead of saving the file or if you hit control +s it runs the macro instead of saving the file Let me know thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to Insert Current Date into cell - Macro to "Save As" | Excel Worksheet Functions | |||
Macro to Save without the Save Message | Excel Discussion (Misc queries) | |||
Save As macro | Excel Programming | |||
ASP: Open Excel File with Macro, Allow Macro to run, and then save | Excel Programming | |||
Prompted to save changes after macro save - why? | Excel Programming |