Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running a macro before saving file

How can I run a macro automatically right before saving a file. So all the user had to do is to click on save and the macro will run.?

Thank
E.B.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Running a macro before saving file

There is a workbook event called BeforeSave. Call you macro in this event
code.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Einollah2001" wrote in message
...
How can I run a macro automatically right before saving a file. So all the

user had to do is to click on save and the macro will run.??

Thanks
E.B.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Running a macro before saving file

Hi
you can use the workbook Beforesave event. enter the following in your
workbook module
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Msgbox "Will save now"
'enter your code here
End Sub

Frank

Einollah2001 wrote:
How can I run a macro automatically right before saving a file. So
all the user had to do is to click on save and the macro will run.??

Thanks
E.B.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running a macro before saving file

Here is what you need to do

1) in the project explorer window, click on "This Worbook"

2) Select "Workbook" in the objects dropdown list

3) Select "BeforeSave" in the events list.

4) the following headers should appear automatically

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel A
Boolean)

End Sub

insert all code between these lines. IF you want to call a procedur
simply type in

call (procedure name

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Running a macro before saving file

Use the BeforeSave event

Not familiar with events? See Chip Pearson's page on the topic

http://www.cpearson.com/excel/events.htm

--
regards,
Tom Ogilvy


Einollah2001 wrote in message
...
How can I run a macro automatically right before saving a file. So all the

user had to do is to click on save and the macro will run.??

Thanks
E.B.



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
Running macro on file open excelnerd Excel Discussion (Misc queries) 3 March 12th 08 10:51 PM
Excel 2007 one network file running (loading and saving) slow Polly Welch Excel Discussion (Misc queries) 0 July 20th 07 11:44 PM
Macro Help for Saving a file [email protected] Excel Worksheet Functions 3 May 12th 06 05:16 PM
How to stop getting the file save box when running a macro Pank Mehta Excel Discussion (Misc queries) 1 March 29th 05 04:05 PM
Saving a new file with a macro Mike[_36_] Excel Programming 0 July 23rd 03 03:55 PM


All times are GMT +1. The time now is 11:11 AM.

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"