Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Run a macro when a workbook is opened

I know its there somewhere but I cannot find help on how to run a macro
which runs automatically when a workbook is opened and again how to run a
macro when a workbook is closed.
I can't figure out how to run open and close events!
Can anyone get me started?



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Run a macro when a workbook is opened

Hi,


Workbook_Open is an "event procedure" and needs to go in
the module of the ThisWorkbook object.

Alt+F11 to the VB editor
In the project explorer window double-click the
ThisWorkbook entry under Microsoft Excel Objects.
In the code window which should now be showing you the
module for ThisWorkbook:
- select Workbook from the left hand dropdown at the top
of the window
- select Open from the right hand dropdown [may have
happened automatically]
- type your code between the lines
Private Sub Workbook_Open()
and
End Sub
which will have been generated automatically.

Regards,

Jan Karel Pieterse
Excel TA/MVP

-----Original Message-----
I know its there somewhere but I cannot find help on how

to run a macro
which runs automatically when a workbook is opened and

again how to run a
macro when a workbook is closed.
I can't figure out how to run open and close events!
Can anyone get me started?



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Run a macro when a workbook is opened

Merevyn,

Name the macros Auto_Open and Auto_Close.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Mervyn Thomas" wrote in message
...
I know its there somewhere but I cannot find help on how to run

a macro
which runs automatically when a workbook is opened and again how

to run a
macro when a workbook is closed.
I can't figure out how to run open and close events!
Can anyone get me started?





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
open workbook b when workbook a opened [email protected] uk Excel Discussion (Misc queries) 5 July 23rd 08 01:02 AM
How to stop Excel remembering/loading macro from previously opened Workbook Norman Yuan Excel Discussion (Misc queries) 4 June 17th 06 04:13 PM
How to run a macro as soon a a workbook (.xls) is opened? Sangamesh Acharya Excel Worksheet Functions 1 December 15th 05 11:15 PM
Workbook copies itself when opened Sundevil249 Excel Worksheet Functions 4 November 30th 05 08:17 PM
Can macro/userform run depending on HOW workbook is opened? grasping@straws Excel Discussion (Misc queries) 1 December 28th 04 03:19 PM


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