Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel template to load automatically as the default template? | Excel Discussion (Misc queries) | |||
Moving Data from Template | Excel Discussion (Misc queries) | |||
need to make a template for weekly calendar ASAP that shows pictu. | Excel Discussion (Misc queries) | |||
Template Wizard with Data Tracking | Excel Discussion (Misc queries) | |||
Template Wizard Addin Program | Excel Discussion (Misc queries) |