View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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