out of range problem in workbook closing

H

hlam

I got an Out of Range error closing a workbook using VBA on one machine but
not the other. Can any one help?

fName = Left(ThisWorkbook.Path, pos) & "SYS01 Report.xls"
Workbooks.Open Filename:=fName
Sheets(1).Select
Sheets(1).Copy Before:=Workbooks("SYS01 Program.xls").Sheets(1)
Workbooks("SYS01 Report").Saved = True
Workbooks("SYS01 Report").Close ... this is the code gets the error
ThisWorkbook.Sheets(1).Name = "CTL"
 
D

Dave Peterson

Try adding .xls to each of these lines:

Workbooks("SYS01 Report").Saved = True
Workbooks("SYS01 Report").Close

Workbooks("SYS01 Report.xls").Saved = True
Workbooks("SYS01 Report.xls").Close

There's a windows setting that allows users to hide/show extensions. To be
careful, you can always include the extension and it'll work no matter the what
the user chose for that setting.
 

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

Top