0

With the below code I am getting the following error for the during Workbooks.Close. The error is "Wrong number of arguments or invalid property assignments".

Here is my code

Range("D2:D61").Select
Selection.ClearContents
Workbooks.Open "c:\Excel\SA2047679.csv"
Range("G2:G61").Select
Selection.Copy
Windows("SA2047679_35.xls").Activate
Range("D2").Select
ActiveSheet.Paste
Range("F2").Select
Workbooks.Close "c:\Excel\SA2047679.csv"

TIA

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by grjohnso
0

Workbooks.Close doesn't require any arguments. It closes all open workbooks.

If you want to close just an individual one, you have to give a reference to it like so:

workbook = workbooks.open("c:\Excel\SA2047679.csv")
workbook.close

Give this a try and let us know if it works.

0

Thanks for the info,

I was able to do something similar which worked.

Windows("SA2047679.csv").Activate
ActiveWindow.Close

Thanks again!

Workbooks.Close doesn't require any arguments. It closes all open workbooks.

If you want to close just an individual one, you have to give a reference to it like so:

workbook = workbooks.open("c:\Excel\SA2047679.csv")
workbook.close

Give this a try and let us know if it works.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.