ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   template path for active workbook? (https://www.excelbanter.com/excel-programming/425794-template-path-active-workbook.html)

Christoph Lutz

template path for active workbook?
 
Hi there,

I have searched high and low but no joy - maybe it's not possible?

I need to find out the path of the template (xlt) for the currently
opened workbook. I need that path because I need to refer to folders
that are relative to the current workbook's template path. That path may
change so hard coding is not really an option.

Something like ActiveWorkbook.AttachedTemplate.path doesn't exist but
gets you the idea of what I'm after....

Anyone??

Thanks so much

Christoph

joel

template path for active workbook?
 
When you open a template you should set a variable to the template like this

Set Tempbk = Workbooks.Open("C:\temp\book1.xls")
TemplatePath = TempBk.Path



"Christoph Lutz" wrote:

Hi there,

I have searched high and low but no joy - maybe it's not possible?

I need to find out the path of the template (xlt) for the currently
opened workbook. I need that path because I need to refer to folders
that are relative to the current workbook's template path. That path may
change so hard coding is not really an option.

Something like ActiveWorkbook.AttachedTemplate.path doesn't exist but
gets you the idea of what I'm after....

Anyone??

Thanks so much

Christoph


joel

template path for active workbook?
 
When you open a template you should set a variable to the template like this

Set Tempbk = Workbooks.Open("C:\temp\book1.xls")
TemplatePath = TempBk.Path



"Christoph Lutz" wrote:

Hi there,

I have searched high and low but no joy - maybe it's not possible?

I need to find out the path of the template (xlt) for the currently
opened workbook. I need that path because I need to refer to folders
that are relative to the current workbook's template path. That path may
change so hard coding is not really an option.

Something like ActiveWorkbook.AttachedTemplate.path doesn't exist but
gets you the idea of what I'm after....

Anyone??

Thanks so much

Christoph


Christoph Lutz

template path for active workbook?
 
Hi,

Thanks for your reply but that doesn't do it. The user will just choose
to double click the template or go to File/New and choose from templates
on his computer. The new file is not opened through code although code
is run on Auto_open when the template is opened. Or am I getting the
wrong end of the stick here?

Christoph

Joel wrote:
When you open a template you should set a variable to the template like this

Set Tempbk = Workbooks.Open("C:\temp\book1.xls")
TemplatePath = TempBk.Path



"Christoph Lutz" wrote:

Hi there,

I have searched high and low but no joy - maybe it's not possible?

I need to find out the path of the template (xlt) for the currently
opened workbook. I need that path because I need to refer to folders
that are relative to the current workbook's template path. That path may
change so hard coding is not really an option.

Something like ActiveWorkbook.AttachedTemplate.path doesn't exist but
gets you the idea of what I'm after....

Anyone??

Thanks so much

Christoph


Dave Peterson

template path for active workbook?
 
Excel doesn't keep track of this kind of information.

Once the workbook has been created, there's no tie-back to the template that was
used.

If you wanted, maybe you could add something to the workbook (a value in a
hidden sheet, or a hidden name) that would help you do whatever you needed.

Christoph Lutz wrote:

Hi there,

I have searched high and low but no joy - maybe it's not possible?

I need to find out the path of the template (xlt) for the currently
opened workbook. I need that path because I need to refer to folders
that are relative to the current workbook's template path. That path may
change so hard coding is not really an option.

Something like ActiveWorkbook.AttachedTemplate.path doesn't exist but
gets you the idea of what I'm after....

Anyone??

Thanks so much

Christoph


--

Dave Peterson

ryguy7272

template path for active workbook?
 
You can retrieve the full path to your application with the full path to your
application:
CurrentProject.FullName
and just the path:
CurrentProject.Path

Good luck,
Ryan---

Christoph Lutz

template path for active workbook?
 
Hi Ryan,

I have seen CurrentProject.FullName in MS Access before but not in
Excel? I get an error using this in Excel and there is no help reference
to that either?

Christoph

ryguy7272 wrote:
You can retrieve the full path to your application with the full path to your
application:
CurrentProject.FullName
and just the path:
CurrentProject.Path

Good luck,
Ryan---


Christoph Lutz

template path for active workbook?
 
Hi Dave,

Thanks for that - I kind of guessed that would be the answer. Trouble is
that putting something in a hidden sheet or cell is as good/bad as
hard-coding it in the code, really. What a shame it seems not possible,
blows the process out of the water, really.

Christoph

Dave Peterson wrote:
Excel doesn't keep track of this kind of information.

Once the workbook has been created, there's no tie-back to the template that was
used.

If you wanted, maybe you could add something to the workbook (a value in a
hidden sheet, or a hidden name) that would help you do whatever you needed.

Christoph Lutz wrote:
Hi there,

I have searched high and low but no joy - maybe it's not possible?

I need to find out the path of the template (xlt) for the currently
opened workbook. I need that path because I need to refer to folders
that are relative to the current workbook's template path. That path may
change so hard coding is not really an option.

Something like ActiveWorkbook.AttachedTemplate.path doesn't exist but
gets you the idea of what I'm after....

Anyone??

Thanks so much

Christoph



Dave Peterson

template path for active workbook?
 
You can use:
workbooks("someworkbook").fullname
to see the path and filename of the workbook.

You can use:
application.Path
to see where the excel.exe file is located.

But neither of these will help determine the location of the template that was
used to create a workbook.

ryguy7272 wrote:

You can retrieve the full path to your application with the full path to your
application:
CurrentProject.FullName
and just the path:
CurrentProject.Path

Good luck,
Ryan---


--

Dave Peterson

Christoph Lutz

template path for active workbook?
 
Yep, that's the conclusion I arrived at. And even

workbooks("someworkbook").fullname

will only work once saved, otherwise it will be blank

Thanks for your help, though

Christoph



Dave Peterson wrote:
You can use:
workbooks("someworkbook").fullname
to see the path and filename of the workbook.

You can use:
application.Path
to see where the excel.exe file is located.

But neither of these will help determine the location of the template that was
used to create a workbook.

ryguy7272 wrote:
You can retrieve the full path to your application with the full path to your
application:
CurrentProject.FullName
and just the path:
CurrentProject.Path

Good luck,
Ryan---



Dave Peterson

template path for active workbook?
 
Not quite blank -- just the name of the workbook.

Christoph Lutz wrote:

Yep, that's the conclusion I arrived at. And even

workbooks("someworkbook").fullname

will only work once saved, otherwise it will be blank

Thanks for your help, though

Christoph

Dave Peterson wrote:
You can use:
workbooks("someworkbook").fullname
to see the path and filename of the workbook.

You can use:
application.Path
to see where the excel.exe file is located.

But neither of these will help determine the location of the template that was
used to create a workbook.

ryguy7272 wrote:
You can retrieve the full path to your application with the full path to your
application:
CurrentProject.FullName
and just the path:
CurrentProject.Path

Good luck,
Ryan---



--

Dave Peterson


All times are GMT +1. The time now is 05:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com