Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 21st, 2003, 10:55 AM
Authorized User
 
Join Date: Nov 2003
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

 
Old November 21st, 2003, 11:17 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old November 21st, 2003, 11:24 AM
Authorized User
 
Join Date: Nov 2003
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.

 
Old November 21st, 2003, 11:38 AM
Friend of Wrox
 
Join Date: Jun 2003
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?
 
Old November 26th, 2003, 10:18 AM
Authorized User
 
Join Date: Nov 2003
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?
 
Old November 26th, 2003, 10:52 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old November 27th, 2003, 01:27 AM
Authorized User
 
Join Date: Nov 2003
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.





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





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