Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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
.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default 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
.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
.





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
Macro buttons opening saved macro Wasabijim Excel Discussion (Misc queries) 0 April 29th 09 08:39 PM
run macro on opening brian thompson3001 via OfficeKB.com Excel Discussion (Misc queries) 5 December 11th 06 09:13 PM
Macro upon opening Peanut Excel Worksheet Functions 1 October 2nd 06 11:25 PM
Run Macro Upon Opening Bill Mosserati[_2_] Excel Programming 1 June 18th 04 05:26 PM
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM


All times are GMT +1. The time now is 12:53 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"