Auto close .csv files

  • Thread starter saman110 via OfficeKB.com
  • 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.
 
D

Dave Peterson

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
 
S

saman110 via OfficeKB.com

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