Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 21st, 2003, 10:55 AM
Authorized User
 
Join Date: Nov 2003
Location: Horby, , Sweden.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Path for a template in VBA

Hi,
I am new to this group and have a problem that I can´t fix in any way at the moment. I start a template in a folder placed somewhere on the computer. After some VBA coding done with it, it will be saved as normal workbook. How is it possible to know the path to the template in VBA, it is easy with an workbook - ActiveWorkbook.Path, but that is not working with templates
Hope for some help in this issue.
Thanks in advance
Piblon

Reply With Quote
  #2 (permalink)  
Old November 21st, 2003, 11:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Unless it is actual the .XLT file you have open for editing, the template doesn't have a path, because it hasn't been saved. It's exactly the same situation as when you open Excel, and have Book1 available - there is no saved file to have a path to.

HTH
Chris


There are two secrets to success in this world:
1. Never tell everything you know
Reply With Quote
  #3 (permalink)  
Old November 21st, 2003, 11:24 AM
Authorized User
 
Join Date: Nov 2003
Location: Horby, , Sweden.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks

It is a xlt-file. then I will have to make the "Template" as a xls-file (read-only) as a possible solution.

Reply With Quote
  #4 (permalink)  
Old November 21st, 2003, 11:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why do you want to know the path to the XLT file in the first place? What are you trying to do?
Reply With Quote
  #5 (permalink)  
Old November 26th, 2003, 10:18 AM
Authorized User
 
Join Date: Nov 2003
Location: Horby, , Sweden.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, im doing a kind of production reporting programme.
Each month ýou start the template, answer a couple of questions and then the template will save into a normal workbook with a filename depending on the answers from the questions.
This is a bit of the code so you know what I mean
docName = Application.GetSaveAsFilename(fileName, "Excel Workbook (*.xls), *.xls", , "Save Stop Report")
ActiveWorkbook.SaveAs docName, xlWorkbookNormal


Quote:
quote:Originally posted by chrislepingwell
 Why do you want to know the path to the XLT file in the first place? What are you trying to do?
Reply With Quote
  #6 (permalink)  
Old November 26th, 2003, 10:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, if that's what you are doing, I don't think you actually need the template's path. What you can do, if you want, is to set
Code:
filename = curdir
, and this will use the last directory used as a starting point. Alternatively, just set a default save location in code, preferably not the same directory as the template - you don't want users breaking things :)
BTW, bear in mind that users can cancel out of the dialog, returning "false", so you must trap that before attempting the save.


There are two secrets to success in this world:
1. Never tell everything you know
Reply With Quote
  #7 (permalink)  
Old November 27th, 2003, 01:27 AM
Authorized User
 
Join Date: Nov 2003
Location: Horby, , Sweden.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx, I will try it out.
I know that cancel = False and working on trapping that issue as well.
Quote:
quote:Originally posted by chrislepingwell
 OK, if that's what you are doing, I don't think you actually need the template's path. What you can do, if you want, is to set
Code:
filename = curdir
, and this will use the last directory used as a starting point. Alternatively, just set a default save location in code, preferably not the same directory as the template - you don't want users breaking things :)
BTW, bear in mind that users can cancel out of the dialog, returning "false", so you must trap that before attempting the save.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with path for loading Pics (app.path) Tabbasum Beginning VB 6 2 November 15th, 2007 04:57 AM
Implementing the all-path shortest path problem bitwords XSLT 1 December 6th, 2006 11:37 AM
using app.path in database path and filename kd8con VB Databases Basics 2 October 25th, 2006 11:45 AM
Unstable VBA in Word Template keytecstaff Word VBA 1 June 5th, 2006 03:47 PM
Convert logical path to absolute path zoostar J2EE 1 April 15th, 2005 10:36 AM



All times are GMT -4. The time now is 09:06 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.