Template with in a macro

Matt

Board Regular
Joined
Feb 16, 2002
Messages
212
I'm having a problem with switching windows in a macro, the file causing the problem is a template file. Assume the template is called template.xlt, have tried the code

windows("Template.xlt").activate

this gives me the error message "Subscript out of range"

I notice that once my template has been updated, Excel renames it as "Template1", and if I run the macro again "Template2". I have tried various ways of activating these files without any joy.

Is there anyway of activating my file?

Thanks

Matt
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi Matt,

I believe that the problem is that you are activating a window that displays the workbook (template) rather than the workbook itself. Since window names are assigned dynamically as you create them, it is sometimes hard to know what the name is. For example, if you have a template named Template1.xlt, then the window name might be "Template1", but if you have more than one window open into Template1, then the two windows will be called "Template1:1" and "Template1:2". If you don't get the name exactly right, you will get the error message you mentioned. I suggest you use

Workbooks("Template1.xlt").Activate

rather than the Window object.
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,175
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top