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

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.