Run Time Error 9, Script Out of Range

J

Jeff Marshall

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top