How to open workbook from workbook template without hardcoding

M

Michael Turner

Hi

Thanks for the answer to my previous question but I left out a vital point
sorry.

Could anyone tell me how to open a workbook from a workbook template, where
both files are in the same folder, without hardcoding the path. I have tried
code like this without success.
Workbooks.open (Thisworkbook.path & "\somefile.xls")

This code works fine when opening a workbook from another workbook, but
not from a template.

Thanks in advance

Mick
 
D

Dave Peterson

If the file that contains the code was based on a template, then you're going to
have to save it before it has a .path property.

(If you created the new workbook in code, then maybe you can use the same folder
as you did then. If you don't know where the template was located (the user
opened it manually), then I think you've got trouble. Excel doesn't keep track
of the originating template location--it's not like word.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top