Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default 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---
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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---

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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---




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Active Workbook Path Dorci Excel Programming 2 February 4th 09 01:52 PM
Determining the full path and filename of an active workbook Aaron Dyck Excel Programming 1 August 31st 06 03:20 AM
Get the path to the directory that the active workbook is in Raman325[_12_] Excel Programming 1 July 1st 05 06:13 PM
Template Path??? caneye Excel Programming 1 April 2nd 04 04:08 PM
How to open a workbook from a template without hardcoding the path Michael Turner Excel Programming 0 November 21st 03 12:08 AM


All times are GMT +1. The time now is 04:49 AM.

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"