Auto close .csv files

  • Thread starter Thread starter saman110 via OfficeKB.com
  • Start date Start date
S

saman110 via OfficeKB.com

hello,

Is it possible to close a .csv file while you are in .xlsm. Here is my
situation, I have a .xlm file and a .csv file open at the save time and I
would like to run a macro that closes the .csv file. My problem is I can not
give it specific file name to close because .csv is auto saves it self every
day with different name, so I have to close all *.csv files.

any help.
thx.
 
You could use a macro that closes all the .csv files:

Option Explicit
Sub testme01()
Dim wkbk As Workbook

For Each wkbk In Application.Workbooks
If LCase(Right(wkbk.Name, 4)) = LCase(".csv") Then
wkbk.Close savechanges:=False
End If
Next wkbk

End Sub
 
Back
Top