![]() |
Run Time Error 9, Script Out of Range
HI,
I am using the code below , but when it gets to; Windows(InvFileName).Activate ; it debugs and says; "Run time error 9, Script out of range. I ran this at home and it worked OK, but at work it crashes. At home i have a laptop with MS Millenium on it. At work I have Windows 98. Does this have anything to do with it ?? Note that InvFileName and NewFolder are both "Public" variables, but declared in a different module. Thanks in advance for any help. Jeff Sub SaveInvAsNewFile() 'name of new folder NewFolder = Format(Now, "yy-mm-dd") & " Invoices" 'Call the name as the text in cell z18 InvFileName = Sheets("InvoiceForm").Cells(18, 26) 'Opens new spreadsheet Workbooks.Add On Error Resume Next ActiveWorkbook.SaveAs Filename:="N:\Invoices\" & NewFolder & "\" & InvFileName & ".xls" On Error GoTo 0 Windows("Generate Report and Invoices.xls").Activate Range("A1:L59").Select Selection.Copy Windows(InvFileName).Activate 'THIS IS THE LINE THAT DEBUGS. |
Run Time Error 9, Script Out of Range
Hi Jeff,
Try Windows(InvFileName & ".xls").Activate Best Regards Bill -----Original Message----- HI, I am using the code below , but when it gets to; Windows(InvFileName).Activate ; it debugs and says; "Run time error 9, Script out of range. I ran this at home and it worked OK, but at work it crashes. At home i have a laptop with MS Millenium on it. At work I have Windows 98. Does this have anything to do with it ?? Note that InvFileName and NewFolder are both "Public" variables, but declared in a different module. Thanks in advance for any help. Jeff Sub SaveInvAsNewFile() 'name of new folder NewFolder = Format(Now, "yy-mm-dd") & " Invoices" 'Call the name as the text in cell z18 InvFileName = Sheets("InvoiceForm").Cells(18, 26) 'Opens new spreadsheet Workbooks.Add On Error Resume Next ActiveWorkbook.SaveAs Filename:="N:\Invoices\" & NewFolder & "\" & InvFileName & ".xls" On Error GoTo 0 Windows("Generate Report and Invoices.xls").Activate Range("A1:L59").Select Selection.Copy Windows(InvFileName).Activate 'THIS IS THE LINE THAT DEBUGS. . |
All times are GMT +1. The time now is 08:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com