![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 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 |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, Colorado USA
Posts: 4,014
|
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.
__________________
Keep Excelling. Damon VBAexpert Excel Consulting (My other life: http://damonostrander.com ) |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
Thanks Damon, I think that is the only solution.
|
|
|
|
|
|
#4 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Hi Matt
If your Workbook is still a template, try windows("Template").activate Providing it's called "Template" of course! _________________ Kind Regards Dave Hawley OzGrid Business Applications Microsoft Excel/VBA Training If it's Excel, then it's us! [ This Message was edited by: Dave Hawley on 2002-03-12 01:08 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|