Option Explicit
Sub SaveAsCsv()
Dim sPath As String
Dim sFile As String
Dim wbSource As Workbook
Dim wbTarget As Workbook
Dim newFileName As String
Dim pos As Long
sPath = "C:\temp\" 'REMEMBER TRAILING BACKSLASH
sFile = Dir(sPath & "*.xlsm")
'disable saving CSV alerts - use error trap to ensure application settings are reset
On Error GoTo errHandler
Application.DisplayAlerts = False
'loop through the folder
Do Until sFile = ""
'open the workbook and build the new file name
Set wbSource = Workbooks.Open(sPath & sFile)
'find the position of the underscore
pos = InStr(wbSource.Name, "_")
'strip out everything before the underscore
newFileName = Right(wbSource.Name, Len(wbSource.Name) - pos)
'add the folder path and re[lace XLSM with CSV
newFileName = sPath & Replace(newFileName, ".xlsm", ".csv")
'ASSUME sheet to be saved as csv is first worksheet
wbSource.Worksheets(1).Copy
Set wbTarget = ActiveWorkbook
wbTarget.SaveAs Filename:=newFileName, FileFormat:=xlCSV
wbTarget.Close SaveChanges:=False
wbSource.Close SaveChanges:=False
'get next fileThis will probably need some editing at your end
Set wbSource = Nothing
Set wbTarget = Nothing
sFile = Dir()
Loop
errHandler:
Application.DisplayAlerts = True
End Sub