Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default ON_OPEN Question

Hello Excel programming gurus (and others),

Assume I have a workbook, call it WB1, open. Then assume that
I open a second workbook (WB2).

Workbook WB2 has nothing in it but data. (It has nothing which
in the way of macros or code of any kind.) Workbook WB1 however
has a large number of macros which will be used to organize,
scan, and reformat the data contained in Workbook WB2.

My question is, is there a way, using macros and code which
is contained in WB1, to capture when WB2 is opened and perform
some set of tasks? I haven't been able to successfully get
the "On_Open" macro in WB1 to fire when I open WB2. (FWIW,
the WB2 names won't always be the same so I can't hardcode
in a specific name to look for.)

Suggestions of how I might be able to do this?

Many thanks, in advance, for any ideas or suggestions.

David


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default ON_OPEN Question

The way to so it is to set a variable to the newly opened workbook, and get
your macros to work on the variable.

Set oWB = Workbooks.Open(filename)

With oWB
do something
.Save
.Close
End With


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"David Schrader" wrote in message
...
Hello Excel programming gurus (and others),

Assume I have a workbook, call it WB1, open. Then assume that
I open a second workbook (WB2).

Workbook WB2 has nothing in it but data. (It has nothing which
in the way of macros or code of any kind.) Workbook WB1 however
has a large number of macros which will be used to organize,
scan, and reformat the data contained in Workbook WB2.

My question is, is there a way, using macros and code which
is contained in WB1, to capture when WB2 is opened and perform
some set of tasks? I haven't been able to successfully get
the "On_Open" macro in WB1 to fire when I open WB2. (FWIW,
the WB2 names won't always be the same so I can't hardcode
in a specific name to look for.)

Suggestions of how I might be able to do this?

Many thanks, in advance, for any ideas or suggestions.

David




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default ON_OPEN Question


You could add a button to a toolbar that would call the code in WB1.
That could be done in the workbook_open event in WB1.
(the button should be removed when the workbook closes)
That assumes your code is written to work on the ActiveWorkbook.
You would want your code to display a message box asking if
the intent is to rearrange the workbook
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"David Schrader"
wrote in message
Hello Excel programming gurus (and others),

Assume I have a workbook, call it WB1, open. Then assume that
I open a second workbook (WB2).

Workbook WB2 has nothing in it but data. (It has nothing which
in the way of macros or code of any kind.) Workbook WB1 however
has a large number of macros which will be used to organize,
scan, and reformat the data contained in Workbook WB2.

My question is, is there a way, using macros and code which
is contained in WB1, to capture when WB2 is opened and perform
some set of tasks? I haven't been able to successfully get
the "On_Open" macro in WB1 to fire when I open WB2. (FWIW,
the WB2 names won't always be the same so I can't hardcode
in a specific name to look for.)

Suggestions of how I might be able to do this?

Many thanks, in advance, for any ideas or suggestions.

David


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
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Refreshing all Pivot Tables in the On_Open() code Tony White Excel Programming 1 January 3rd 05 10:03 PM
Checking & installing references as part of on_open KR Excel Programming 6 December 3rd 04 05:35 PM
Auto_open or On_open Nathan Gutman Excel Programming 1 December 5th 03 09:21 PM
On_Open color coding Phil Hageman Excel Programming 3 August 7th 03 11:18 PM


All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"