Simple VBA help

Copper Contributor

Greetings,

 

I have this simple VBA Macro that coverts all the files in a workbook to individual CSV files. However i would like to get the workbook name to be a a part of the directory . Also is for the code to be retro fitted so that i can convert all the workbooks in the directory.

 

Public Sub SaveWorksheetsAsCsv()
Dim xWs As Worksheet
Dim xDir As String
Dim folder As FileDialog
Set folder = Application.FileDialog(msoFileDialogFolderPicker)
If folder.Show <> -1 Then Exit Sub
xDir = folder.SelectedItems(1)
For Each xWs In Application.ActiveWorkbook.Worksheets
xWs.SaveAs xDir & "\" & xWs.Name, xlCSV
Next
End Sub

 

 

Cheers.

0 Replies