#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AutoOpen

I am trying to write a macro that will run each time I open a particular
workbook. The macro has been written, tested and stored in the workbook but I
cannot find out how to run it when I open the workbook.

I would also like to perform a Save As of this workbook if the workbook name
equals MyWorkbook but allow a regular save if the name does not equal
MyWorkbook.

Thanks, I appreciate the help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default AutoOpen

Sounds like you've got the hang of macros already, just need some exposure
to events.

From VBA, doubleclick the ThisWorkbook object and insert this code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
MsgBox ThisWorkbook.Name
End Sub

Private Sub Workbook_Open()
MsgBox "Workbook_Open"
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Tom Renoe" <Tom wrote in message
...
I am trying to write a macro that will run each time I open a particular
workbook. The macro has been written, tested and stored in the workbook
but I
cannot find out how to run it when I open the workbook.

I would also like to perform a Save As of this workbook if the workbook
name
equals MyWorkbook but allow a regular save if the name does not equal
MyWorkbook.

Thanks, I appreciate the help!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default AutoOpen

You can also keep your macro in a general module, but name it: Auto_open
(note the underscore)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

If you're new to events, David also has notes at:
http://www.mvps.org/dmcritchie/excel/event.htm

Chip Pearson also has some notes about events at:
http://www.cpearson.com/excel/events.htm

(just to add to Rob's reply)

Tom Renoe wrote:

I am trying to write a macro that will run each time I open a particular
workbook. The macro has been written, tested and stored in the workbook but I
cannot find out how to run it when I open the workbook.

I would also like to perform a Save As of this workbook if the workbook name
equals MyWorkbook but allow a regular save if the name does not equal
MyWorkbook.

Thanks, I appreciate the help!


--

Dave Peterson
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
How to disable autoopen() programmatically Karl Steinam Excel Programming 2 September 30th 04 06:35 PM
'Yes' 'No' button on autoopen macro Larry Excel Programming 2 May 21st 04 09:59 PM
Disable AutoOpen macro's Michael Beckinsale Excel Programming 1 October 16th 03 01:48 PM


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

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"