#1   Report Post  
nc
 
Posts: n/a
Default Template

Hi

In my VBA code I am referencing Template1. The problem
is sometimes the template opens as Template2/3/4 etc. and
I get an error message. Is there a way of referencing
templates to avoid errors.

Thanks.
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Maybe you could use ThisWorkbook if the code is in the workboook based on that
template.

If you're opening the template from another macro, you could use a variable that
represents that new workbook and use that:

Dim wkbk As Workbook
Set wkbk = Workbooks.Add(template:="C:\my documents\excel\book1.xlt")
wkbk.Worksheets(1).Range("a1").Value = "hi"
.....


nc wrote:

Hi

In my VBA code I am referencing Template1. The problem
is sometimes the template opens as Template2/3/4 etc. and
I get an error message. Is there a way of referencing
templates to avoid errors.

Thanks.


--

Dave Peterson
  #3   Report Post  
nc
 
Posts: n/a
Default

Hi Dave

Thanks a lot. It solved my problem.


-----Original Message-----
Maybe you could use ThisWorkbook if the code is in the

workboook based on that
template.

If you're opening the template from another macro, you

could use a variable that
represents that new workbook and use that:

Dim wkbk As Workbook
Set wkbk = Workbooks.Add(template:="C:\my

documents\excel\book1.xlt")
wkbk.Worksheets(1).Range("a1").Value = "hi"
.....


nc wrote:

Hi

In my VBA code I am referencing Template1. The problem
is sometimes the template opens as Template2/3/4 etc.

and
I get an error message. Is there a way of referencing
templates to avoid errors.

Thanks.


--

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
Excel template to load automatically as the default template? David Excel Discussion (Misc queries) 1 March 21st 05 12:24 PM
Moving Data from Template [email protected](donotspam) Excel Discussion (Misc queries) 0 March 10th 05 02:51 PM
need to make a template for weekly calendar ASAP that shows pictu. questn1office Excel Discussion (Misc queries) 1 March 9th 05 12:05 AM
Template Wizard with Data Tracking Dee G Excel Discussion (Misc queries) 3 February 1st 05 01:59 PM
Template Wizard Addin Program millemj Excel Discussion (Misc queries) 7 December 11th 04 08:32 PM


All times are GMT +1. The time now is 04:27 PM.

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"