Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Assign a macro to the save button

Hi,

I have just learnt how to use macro's and i was wondering if you could
assign the macro so it runs everytime I press the save button.

I would only want the macro to work on this worksheet, no others!!!

Here is my macro below (Very simple), to protect all work sheets when the
button is pressed. But i would like this to be assign to the save button

Sub Macro3()
'
' Macro3 Macro
'

'
Sheets("Sheet3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

Hope you can help!!!!!

--
Jonno
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Assign a macro to the save button

From workbook launch VBE using short-key Alt+F11. On the left treeview under
'VBA Project(workbookname.xls) Microsoft Excel Objects double click 'This
Workbook' and paste the below code to the code panel.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call Macro3
End Sub

This is the BeforeSave event which triggers just before you save the
workbook. Call Macro3 will call your macro which exists in one of the
modules..of the same workbook

If this post helps click Yes
---------------
Jacob Skaria


"Jonno" wrote:

Hi,

I have just learnt how to use macro's and i was wondering if you could
assign the macro so it runs everytime I press the save button.

I would only want the macro to work on this worksheet, no others!!!

Here is my macro below (Very simple), to protect all work sheets when the
button is pressed. But i would like this to be assign to the save button

Sub Macro3()
'
' Macro3 Macro
'

'
Sheets("Sheet3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

Hope you can help!!!!!

--
Jonno

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Assign a macro to the save button

This works great thank you very much.

What would i do if i wanted to add more macros before saving I.e Macro 1 or
2, or both aswell?
--
Jonno


"Jacob Skaria" wrote:

From workbook launch VBE using short-key Alt+F11. On the left treeview under
'VBA Project(workbookname.xls) Microsoft Excel Objects double click 'This
Workbook' and paste the below code to the code panel.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call Macro3
End Sub

This is the BeforeSave event which triggers just before you save the
workbook. Call Macro3 will call your macro which exists in one of the
modules..of the same workbook

If this post helps click Yes
---------------
Jacob Skaria


"Jonno" wrote:

Hi,

I have just learnt how to use macro's and i was wondering if you could
assign the macro so it runs everytime I press the save button.

I would only want the macro to work on this worksheet, no others!!!

Here is my macro below (Very simple), to protect all work sheets when the
button is pressed. But i would like this to be assign to the save button

Sub Macro3()
'
' Macro3 Macro
'

'
Sheets("Sheet3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

Hope you can help!!!!!

--
Jonno

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Assign a macro to the save button

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call Macro1
Call Macro2
Call Macro3
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jonno" wrote:

This works great thank you very much.

What would i do if i wanted to add more macros before saving I.e Macro 1 or
2, or both aswell?
--
Jonno


"Jacob Skaria" wrote:

From workbook launch VBE using short-key Alt+F11. On the left treeview under
'VBA Project(workbookname.xls) Microsoft Excel Objects double click 'This
Workbook' and paste the below code to the code panel.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call Macro3
End Sub

This is the BeforeSave event which triggers just before you save the
workbook. Call Macro3 will call your macro which exists in one of the
modules..of the same workbook

If this post helps click Yes
---------------
Jacob Skaria


"Jonno" wrote:

Hi,

I have just learnt how to use macro's and i was wondering if you could
assign the macro so it runs everytime I press the save button.

I would only want the macro to work on this worksheet, no others!!!

Here is my macro below (Very simple), to protect all work sheets when the
button is pressed. But i would like this to be assign to the save button

Sub Macro3()
'
' Macro3 Macro
'

'
Sheets("Sheet3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

Hope you can help!!!!!

--
Jonno

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Assign a macro to the save button

Great thank you very much!!!!!
--
Jonno


"Jacob Skaria" wrote:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call Macro1
Call Macro2
Call Macro3
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jonno" wrote:

This works great thank you very much.

What would i do if i wanted to add more macros before saving I.e Macro 1 or
2, or both aswell?
--
Jonno


"Jacob Skaria" wrote:

From workbook launch VBE using short-key Alt+F11. On the left treeview under
'VBA Project(workbookname.xls) Microsoft Excel Objects double click 'This
Workbook' and paste the below code to the code panel.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call Macro3
End Sub

This is the BeforeSave event which triggers just before you save the
workbook. Call Macro3 will call your macro which exists in one of the
modules..of the same workbook

If this post helps click Yes
---------------
Jacob Skaria


"Jonno" wrote:

Hi,

I have just learnt how to use macro's and i was wondering if you could
assign the macro so it runs everytime I press the save button.

I would only want the macro to work on this worksheet, no others!!!

Here is my macro below (Very simple), to protect all work sheets when the
button is pressed. But i would like this to be assign to the save button

Sub Macro3()
'
' Macro3 Macro
'

'
Sheets("Sheet3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

Hope you can help!!!!!

--
Jonno

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
Assign a macro to a button totofab Excel Discussion (Misc queries) 4 December 13th 07 06:16 PM
Assign a macro to a command button SheriTingle Excel Discussion (Misc queries) 4 September 25th 06 06:38 PM
How do I Assign Macro to a button? BellExcel Charts and Charting in Excel 4 May 20th 05 07:21 PM
How to assign a macro to a commnd button Mickey Blue Eyes Excel Discussion (Misc queries) 2 January 4th 05 02:15 PM
assign a macro to a control button ewan72 Excel Discussion (Misc queries) 1 December 3rd 04 02:04 PM


All times are GMT +1. The time now is 10:17 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"