Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Insert Current Date into cell - Macro to "Save As" Guy[_2_] Excel Worksheet Functions 4 December 12th 08 08:20 PM
Macro to Save without the Save Message Ellen G Excel Discussion (Misc queries) 4 February 23rd 07 08:52 PM
Save As macro BigDave[_4_] Excel Programming 3 June 8th 05 05:10 PM
ASP: Open Excel File with Macro, Allow Macro to run, and then save delgados129 Excel Programming 0 March 10th 05 09:35 PM
Prompted to save changes after macro save - why? Izar Arcturus Excel Programming 2 December 10th 03 09:27 PM


All times are GMT +1. The time now is 06:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"