ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do you get a macro to run upon opening a SpSheet (https://www.excelbanter.com/excel-programming/308003-how-do-you-get-macro-run-upon-opening-spsheet.html)

kate

How do you get a macro to run upon opening a SpSheet
 
Hi,

I have a macro already built into the spreadsheet, but I
need to add a code that would make the macro run when the
spreadsheet is initially opened by the user.

Any ideas???

Thanks.
Kate

Stephen Rasey[_2_]

How do you get a macro to run upon opening a SpSheet
 
When the Spreadsheet is Activated
Or when the Workbook is Opened?
You probably mean the latter, but it matters.

In the Visual Basic Editor, Project Window,
Right click on the ThisWorkbook item. (it is just above the Modules
folder).
Choose View Code
It will be blank.
In the left drop down box in the Edit window (it will say "(General)"),
choose Workbook.
In the right Drop Down, Choose Open (by default.

Private Sub Workbook_Open()
MyMacro
End Sub

A word of advice. Almost all you VBA in the Modules. Only put calls to
modules in the this "code behind".

Stephen Rasey
Houston
http://wiserways.com
http://excelsig.org

"Kate" wrote in message
...
Hi,

I have a macro already built into the spreadsheet, but I
need to add a code that would make the macro run when the
spreadsheet is initially opened by the user.

Any ideas???

Thanks.
Kate




Kris

How do you get a macro to run upon opening a SpSheet
 
Hello Kate,

Name your macro Auto_Open

i.e.

Sub Auto_Open()
'your code
End Sub

Hope this helps,

Kris

-----Original Message-----
Hi,

I have a macro already built into the spreadsheet, but I
need to add a code that would make the macro run when

the
spreadsheet is initially opened by the user.

Any ideas???

Thanks.
Kate
.


Ron de Bruin

How do you get a macro to run upon opening a SpSheet
 
Hi Kate

Sub Auto_open()
MsgBox "Hi"
End Sub

Must be in a normal module
If you use a Auto_open macro then this wil not run if you open the file with a macro


Private Sub Workbook_Open()
Msgbox "Workbook Opened"
End Sub

Must be in the Thisworkbook module


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Kate" wrote in message ...
Hi,

I have a macro already built into the spreadsheet, but I
need to add a code that would make the macro run when the
spreadsheet is initially opened by the user.

Any ideas???

Thanks.
Kate




Stephen Rasey[_2_]

How do you get a macro to run upon opening a SpSheet
 
I'll be... It is not in the help, but Auto_Open works.

Stephen Rasey

"Kris" wrote in message
...
Hello Kate,

Name your macro Auto_Open

i.e.

Sub Auto_Open()
'your code
End Sub

Hope this helps,

Kris

-----Original Message-----
Hi,

I have a macro already built into the spreadsheet, but I
need to add a code that would make the macro run when

the
spreadsheet is initially opened by the user.

Any ideas???

Thanks.
Kate
.




Frank Stone

How do you get a macro to run upon opening a SpSheet
 
hi,
yes. move the code to the workbooks Open event.
open the workbook. then open VB editor. open the module
your code is in. copy it. in the project pane, douple
click this workbook. above the code window, click the righ
box,select workbook. on the left side box , click open.
Paste your code in the code window.
the macro should fire when the work book is opne.
-----Original Message-----
Hi,

I have a macro already built into the spreadsheet, but I
need to add a code that would make the macro run when the
spreadsheet is initially opened by the user.

Any ideas???

Thanks.
Kate
.


Tom Ogilvy

How do you get a macro to run upon opening a SpSheet
 
http://www.cpearson.com/excel/events.htm
Chip Pearson's page on events
--
Regards,
Tom Ogilvy

"Kate" wrote in message
...
Hi,

I have a macro already built into the spreadsheet, but I
need to add a code that would make the macro run when the
spreadsheet is initially opened by the user.

Any ideas???

Thanks.
Kate




Tom Ogilvy

How do you get a macro to run upon opening a SpSheet
 
Workbook_open wasn't introduced until xl97. xl5 and xl95 used Auto_open and
Auto_close. Before that, the xl4 macro language used Auto_open xl4 macros.

--
Regards,
Tom Ogilvy

"Stephen Rasey" wrote in message
...
I'll be... It is not in the help, but Auto_Open works.

Stephen Rasey

"Kris" wrote in message
...
Hello Kate,

Name your macro Auto_Open

i.e.

Sub Auto_Open()
'your code
End Sub

Hope this helps,

Kris

-----Original Message-----
Hi,

I have a macro already built into the spreadsheet, but I
need to add a code that would make the macro run when

the
spreadsheet is initially opened by the user.

Any ideas???

Thanks.
Kate
.







All times are GMT +1. The time now is 02:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com