PDA

View Full Version : Macro To Close All CSV Files



Howardc
06-06-2013, 02:30 PM
I would like a macro to close all open .csv files

macro tto close all csv files (http://www.mrexcel.com/forum/excel-questions/706530-macro-tto-close-all-csv-files.html)

Excel Fox
06-06-2013, 07:17 PM
Use this


Sub CloseCSV()

Dim wbk As Workbook

For Each wbk In Workbooks
If wbk.FileFormat = 6 Then
wbk.Close 0
End If
Next wbk

End Sub

Howardc
06-06-2013, 07:33 PM
Hi

Thanks for the help, much appreciated

Howardc
03-15-2014, 12:44 PM
Hi ExcelFox

I while back you provided me with code to close csv files that are open.It worked previosly, but when using it, one of the csv files won't close called

BR1 SalesLedgerOutstandingTransactions.csv

It would be appreciated if you would assist




For Each wbk In Workbooks
If wbk.FileFormat = 6 Then
wbk.Close 0
End If
Next wbk

End Sub

snb
03-15-2014, 04:04 PM
Check the fiteformat of that file.

Howardc
03-15-2014, 05:24 PM
Thanks for the reply

I sorted out the problem, by amending the code slightly



For Each wbk In Workbooks
If wbk.FileFormat = xlcsv Then
wbk.Close
End If
Next wbk

End Sub