How to launch Macro/Code form command line

P

Phil Smith

I want a Macro to run when a spreadsheet is opened SOME OF THE TIME. I
know about Auto_Open but it runs everytime you open the spreadsheet. I
do not want this. I want to be able to decide, based on a command line
call, whether or not to run the macro in question.

Excel 2003.

Ideas?
 
J

Jim Cone

Code in an Auto_Open sub does Not run when the workbook is opened via code,
however Workbook_Open code does run.

You can use the RunAutoMacros method when opening a workbook via code
to run Auto_Open code.

Someplace in there, I think, is an answer to your question.
--
Jim Cone
Portland, Oregon USA




"Phil Smith" <[email protected]>
wrote in message
I want a Macro to run when a spreadsheet is opened SOME OF THE TIME. I
know about Auto_Open but it runs everytime you open the spreadsheet. I
do not want this. I want to be able to decide, based on a command line
call, whether or not to run the macro in question.
Excel 2003.
Ideas?
 
R

rpick60

I have used a message box in the auto open macro that prompts to
update tthe data or not.
It ahould be placed at the beginning of your auto open macro

'message box to update or not
Dim Msg, Title, Response As String
Msg = "Do you want to update the data?"
Title = "Update new data"
Response = MsgBox(Msg, vbYesNo + vbQuestion, Title)
If Response = vbNo Then
Exit Sub ' Quit the macro
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top