Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
default template Excel uses at start-up | New Users to Excel | |||
How to open connected workbook with template | Excel Programming | |||
Dropdown list connected to another workbook | Excel Worksheet Functions | |||
how do i start excel and have it use a template automatically? | Excel Programming | |||
Anyne have a template for a start-up business plan? | Excel Discussion (Misc queries) |