Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How to start template with connected workbook

Hi,
I've developed a workbook wb1 with a connected workbook wb2. Wb2 is open
with VBA in the Workbook_Open():

Workbooks.Open(ThisWorkbook.Path & "\wb2.xls", 0, True)

Now I've changed wb1 into a template. When I now make a new workbook based
on the template the Workbook_Open() macro is executed. But now
ThisWorkbook.Path is empty! And the connected wb2 cannot be found.

What can I do to open wb2 in this situation?

Thanks for help,

Henk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to start template with connected workbook

As you have observed, a workbook created from a template has no path until
the workbook is saved.

You could have the open event check for this condition and when found
instruct the user to save the workbook (perhaps close and reopen or use the
BeforeSave event to trigger a delayed macro [using application.ontime] to
open the wb2).

Of course if the open event found the workbook had a path, it could go ahead
and open wb2

Another approach would be to set a reference to Wb2 from the VBE for wb1.

If WB1 will be distributed to different locations, then this would be harder
to manage. If you were only making it a template so the contents would not
be altered and it would always be in one location, this would be OK, but
then you could just hardcode this location in the workbook open.

--
Regards,
Tom Ogilvy




"hstijnen" wrote in message
...
Hi,
I've developed a workbook wb1 with a connected workbook wb2. Wb2 is open
with VBA in the Workbook_Open():

Workbooks.Open(ThisWorkbook.Path & "\wb2.xls", 0, True)

Now I've changed wb1 into a template. When I now make a new workbook based
on the template the Workbook_Open() macro is executed. But now
ThisWorkbook.Path is empty! And the connected wb2 cannot be found.

What can I do to open wb2 in this situation?

Thanks for help,

Henk



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How to start template with connected workbook

Thanks, Tom, for your suggestions. Indeed the template will be stored in
different maps, for it is to be distributed via internet. When the user saves
his workbook, it will get a path, but then also the path to the template map
is not known.

In the meantime I've surrouded the problem by copying WB2 into WB1.

"Tom Ogilvy" wrote:

As you have observed, a workbook created from a template has no path until
the workbook is saved.

You could have the open event check for this condition and when found
instruct the user to save the workbook (perhaps close and reopen or use the
BeforeSave event to trigger a delayed macro [using application.ontime] to
open the wb2).

Of course if the open event found the workbook had a path, it could go ahead
and open wb2

Another approach would be to set a reference to Wb2 from the VBE for wb1.

If WB1 will be distributed to different locations, then this would be harder
to manage. If you were only making it a template so the contents would not
be altered and it would always be in one location, this would be OK, but
then you could just hardcode this location in the workbook open.

--
Regards,
Tom Ogilvy




"hstijnen" wrote in message
...
Hi,
I've developed a workbook wb1 with a connected workbook wb2. Wb2 is open
with VBA in the Workbook_Open():

Workbooks.Open(ThisWorkbook.Path & "\wb2.xls", 0, True)

Now I've changed wb1 into a template. When I now make a new workbook based
on the template the Workbook_Open() macro is executed. But now
ThisWorkbook.Path is empty! And the connected wb2 cannot be found.

What can I do to open wb2 in this situation?

Thanks for help,

Henk




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
default template Excel uses at start-up Mel New Users to Excel 3 November 1st 07 05:06 PM
How to open connected workbook with template hstijnen Excel Programming 0 October 13th 06 11:12 AM
Dropdown list connected to another workbook Pieman Excel Worksheet Functions 5 March 12th 06 09:35 PM
how do i start excel and have it use a template automatically? Vasant Nanavati Excel Programming 1 August 10th 05 08:45 PM
Anyne have a template for a start-up business plan? dbb Excel Discussion (Misc queries) 0 May 30th 05 11:35 PM


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