Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > PC based Database Applications > Microsoft Excel > disable/re-enable Workbook_Open() and howto save as Text()today

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-04, 12:40
alienscript alienscript is offline
Registered User
 
Join Date: Jul 2004
Posts: 23
disable/re-enable Workbook_Open() and howto save as Text()today

Hi VB expert,

In my Excel 2002 template (let's say template.xls) I have a macro that auto-populates the required cells. I name the macro as MacroStockingUpdate in the Standard Module.

This Excel 2002 template has an Auto-Start macro in ThisWorkbook as below:


Private Sub Workbook_Open()
Call MacroStockingUpdate
End Sub


After the auto-execution tasks are done, I save it as StockingStatus.xls.
My problem is that when the viewers open StockingStatus.xls, it also load Workbook_Open() and I do not want that.

(1) what VB code would disable the Workbook_Open() after I saved it as StockingStatus.xls ?
(2) what VB code would enable again the Workbook_Open() when I saved it back as template.xls after erasing the populated data ?
(3) what VB code to allow me to save the worksheet as "StockingStatus" with System ()today's date (eg. StockingStatus_10-Oct-2004, or any other date format as long as it's today) ?


Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 10-08-04, 10:49
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 525
Quote:
Originally Posted by alienscript
Hi VB expert,

(1) what VB code would disable the Workbook_Open() after I saved it as StockingStatus.xls ?
(2) what VB code would enable again the Workbook_Open() when I saved it back as template.xls after erasing the populated data ?
(3) what VB code to allow me to save the worksheet as "StockingStatus" with System ()today's date (eg. StockingStatus_10-Oct-2004, or any other date format as long as it's today) ?


Thanks in advance.
Here's some examples to do what you asked.
Code:
' (1) and (2) Private Sub Workbook_Open() ' Put this line in your workbook_open ' Event. If Not ThisWorkbook.Name = "template.xls" Then Exit Sub End If End Sub ' (3) Sub SaveWorkbook() strAppend = Format(Date, "DD-MMM-YYYY") strPath = "C:\Documents and Settings\Owner\My Documents\" fSaveName = strPath & "StockingStatus_" & strAppend ThisWorkbook.SaveAs fSaveName End Sub
__________________
~

Bill
Reply With Quote
  #3 (permalink)  
Old 10-12-04, 12:46
alienscript alienscript is offline
Registered User
 
Join Date: Jul 2004
Posts: 23
It works great !
Thanks so much.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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