Thread: Template
View Single Post
  #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