Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Running a Script upon Saving a File

I was wondering if someone can help me.

I am trying to help a friend with a project he is working on. He is using
excel to store and manage simple inventory data. (He won't use Access.) He
wants to keep track of who/when someone makes changing to the file and saves
it. So, he asked me to write a script to do this for him.

Let say I make a change to the data contained in the worksheets and then
save the file. He would like a script to be run that would ask for a name and
store that information along with the date stored in the worksheet that was
changed.

Unfortunately, its been a while since I last wrote anything in Visual Basic.
I also do not know if you can do such a thing when someone saves a file.

The only thing I can think of is to have a macro on each sheet and have them
click it whenever they change something. Is there a better way?

I would appreciate any assistance or advice anyone would like to offer.

Thanks,

-Michael

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Running a Script upon Saving a File

Let say I make a change to the data contained in the worksheets and then
save the file. He would like a script to be run that would ask for a name and
store that information along with the date stored in the worksheet that was
changed.



It sounds like you want to use the workbook's BeforeSave Event :

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

'code here

End Sub

In the VBA Editor window, use View-Project Explorer, then select
ThisWorkbook , use the left dropbox at the top to select Workbook, and then
the right drop box to select BeforeSave
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Running a Script upon Saving a File

Start out by looking at Chip Pearson's page on events

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

Looks like you would be interested in the workbook level Change event and
the BeforeSave event.

--
Regards,
Tom Ogilvy


"Michael" wrote in message
...
I was wondering if someone can help me.

I am trying to help a friend with a project he is working on. He is using
excel to store and manage simple inventory data. (He won't use Access.) He
wants to keep track of who/when someone makes changing to the file and

saves
it. So, he asked me to write a script to do this for him.

Let say I make a change to the data contained in the worksheets and then
save the file. He would like a script to be run that would ask for a name

and
store that information along with the date stored in the worksheet that

was
changed.

Unfortunately, its been a while since I last wrote anything in Visual

Basic.
I also do not know if you can do such a thing when someone saves a file.

The only thing I can think of is to have a macro on each sheet and have

them
click it whenever they change something. Is there a better way?

I would appreciate any assistance or advice anyone would like to offer.

Thanks,

-Michael



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Running a Script upon Saving a File

Got it! Thanks guys!

"mark" wrote:

Let say I make a change to the data contained in the worksheets and then
save the file. He would like a script to be run that would ask for a name and
store that information along with the date stored in the worksheet that was
changed.



It sounds like you want to use the workbook's BeforeSave Event :

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

'code here

End Sub

In the VBA Editor window, use View-Project Explorer, then select
ThisWorkbook , use the left dropbox at the top to select Workbook, and then
the right drop box to select BeforeSave

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
Excel 2007 one network file running (loading and saving) slow Polly Welch Excel Discussion (Misc queries) 0 July 20th 07 11:44 PM
can't save VBA script when saving excel file thinktwice Excel Discussion (Misc queries) 5 December 27th 06 07:38 AM
when i save xls file, debug script is running and canno't save fil Imtiaz Excel Discussion (Misc queries) 1 July 16th 05 03:47 PM
running vbs script from vba? John Gunn Excel Programming 1 November 13th 04 01:08 AM
Running a macro before saving file Einollah2001 Excel Programming 4 February 10th 04 12:21 AM


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