PC Review


Reply
Thread Tools Rate Thread

Autorun a macro on save

 
 
Udo
Guest
Posts: n/a
 
      2nd Apr 2009
Hi Excelperts,

there are several macros I created that run automatically when the
workbook is opened. I have also some on closing the workbook. But I
couldn't figure out yet how to make a macro run when the file is
saved. To be very specific: if you close the file without saving, it
should not run, only when the file is saved. This is when you close
and save in one step or when you save it and continue to work on it.
I've tried workbook_save, on_save, auto_save. but it didn't work out.
So, any hint how to do it?

Thanks in advance
hamster
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      2nd Apr 2009
I do it like this:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call '...you macro here
End Sub

Those three lines fo code go into 'ThisWorkbook' sheet.

HTH,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Udo" wrote:

> Hi Excelperts,
>
> there are several macros I created that run automatically when the
> workbook is opened. I have also some on closing the workbook. But I
> couldn't figure out yet how to make a macro run when the file is
> saved. To be very specific: if you close the file without saving, it
> should not run, only when the file is saved. This is when you close
> and save in one step or when you save it and continue to work on it.
> I've tried workbook_save, on_save, auto_save. but it didn't work out.
> So, any hint how to do it?
>
> Thanks in advance
> hamster
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Microsoft Excel Programming 3 20th Oct 2011 09:01 PM
autorun a macro adenbutter@gmail.com Microsoft Excel New Users 2 24th Jan 2008 05:41 PM
How do I save Powerpoint as autorun DVD? shutterfly32 Microsoft Powerpoint 3 20th Dec 2007 08:05 AM
Autorun macro MikeM Microsoft Excel Discussion 3 7th Oct 2004 10:40 PM
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Microsoft Excel Programming 2 25th May 2004 06:59 PM


Features
 

Advertising
 

Newsgroups
 


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