Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically run VB code on workbook save event

Is it possible to have the workbook save event trigger VB
code to run in Excel? I know you can do it in ACCESS. If
so, how would I do that?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Automatically run VB code on workbook save event

Tim, do it like this, put in thisworkbook code

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
'your code here
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 97 & 2000
** remove news from my email address to reply by email **

"Tim" wrote in message
...
Is it possible to have the workbook save event trigger VB
code to run in Excel? I know you can do it in ACCESS. If
so, how would I do that?

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
tim tim is offline
external usenet poster
 
Posts: 1
Default Automatically run VB code on workbook save event

Paul,

Thank you for the suggestion. I keep getting a fatal
error. It saves the csv, but then the actual save fails.
Unfortunately I think I need to run my code after save and
I did not see that as an event. Any ideas?

Here is my code:

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

Dim filename$
filename = "c:\daily manual trade totals1.csv"

ActiveWorkbook.SaveAs filename:=filename,
FileFormat:=xlCSV, CreateBackup:=False

End Sub


-----Original Message-----
Tim, do it like this, put in thisworkbook code

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As

Boolean, Cancel As
Boolean)
'your code here
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can

benefit from it
Feedback on answers is always appreciated!
Using Excel 97 & 2000
** remove news from my email address to reply by email **

"Tim" wrote in message
...
Is it possible to have the workbook save event trigger

VB
code to run in Excel? I know you can do it in ACCESS.

If
so, how would I do that?

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
automatically save a read-only workbook with client last name John Galt[_2_] Excel Discussion (Misc queries) 2 January 13th 09 07:47 PM
can not save if this code is in the workbook jlclyde Excel Discussion (Misc queries) 0 December 17th 08 10:21 PM
Workbook event code won't work on laptop SoupNazi Excel Worksheet Functions 1 April 20th 07 11:38 PM
Save Event - Determine if called by code or user David Sedberry Excel Programming 0 October 2nd 03 04:56 PM
After save event Bart[_3_] Excel Programming 2 July 22nd 03 12:07 PM


All times are GMT +1. The time now is 01:10 PM.

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

About Us

"It's about Microsoft Excel"