Hello VBA experts,
There is a wonderful code that I would like to reuse. Could you please help me to amend the code to open xls files in a SharePoint folder and save in the same SharePoint folder csv files?
Many thanks and kind regards
Mira Abel
Option Explicit
Sub ConvertToCSV()
'The following has been adapted from here:
'https://msdn.microsoft.com/en-us/vba/excel-vba/articles/application-filedialog-property-excel
Dim lngCount As Long
Dim objFSO As Object
Application.ScreenUpdating = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "D:\Robert\USB Backup 18-Jan-2018\ROB'S USB\Excel\Samples\" 'Initial file path. Don't forget trailing backslash.
'Add a custom filter to list Excel files only
With .Filters
.Clear
.Add "Excel Files Only", "*.xls*"
End With
.AllowMultiSelect = True
.Show
'Loop through each file selected, converting them to a CSV format.
'//Note that as a *.csv file can only have a single tab the sheet the *.xls*' workbook opens on will be the *.csv file//
For lngCount = 1 To .SelectedItems.Count
'Open Workbook
Workbooks.Open Filename:=.SelectedItems(lngCount)
'Turn alters off
Application.DisplayAlerts = False
'Save the active tab as a *.csv file
ActiveWorkbook.SaveAs Filename:=objFSO.GetParentFolderName(.SelectedItems(lngCount)) & "\" & objFSO.GetBaseName(.SelectedItems(lngCount)) & ".csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close False
Application.ScreenUpdating = True
Next lngCount
End With
Set objFSO = Nothing
Application.ScreenUpdating = True
End Sub
There is a wonderful code that I would like to reuse. Could you please help me to amend the code to open xls files in a SharePoint folder and save in the same SharePoint folder csv files?
Many thanks and kind regards
Mira Abel
I Love This VBA for Multiple .xlsx Files Converted to .csv Files Except...
Hi...My name is Robert, and I am a schoolteacher who is taking a dip in the Excel VBA pool. I consider myself to be very knowledgeable of using spreadsheet formulas, but I am definitely an amateur when it comes to coding. I am trying to control my frustration of not being able to find the...
www.mrexcel.com
Option Explicit
Sub ConvertToCSV()
'The following has been adapted from here:
'https://msdn.microsoft.com/en-us/vba/excel-vba/articles/application-filedialog-property-excel
Dim lngCount As Long
Dim objFSO As Object
Application.ScreenUpdating = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "D:\Robert\USB Backup 18-Jan-2018\ROB'S USB\Excel\Samples\" 'Initial file path. Don't forget trailing backslash.
'Add a custom filter to list Excel files only
With .Filters
.Clear
.Add "Excel Files Only", "*.xls*"
End With
.AllowMultiSelect = True
.Show
'Loop through each file selected, converting them to a CSV format.
'//Note that as a *.csv file can only have a single tab the sheet the *.xls*' workbook opens on will be the *.csv file//
For lngCount = 1 To .SelectedItems.Count
'Open Workbook
Workbooks.Open Filename:=.SelectedItems(lngCount)
'Turn alters off
Application.DisplayAlerts = False
'Save the active tab as a *.csv file
ActiveWorkbook.SaveAs Filename:=objFSO.GetParentFolderName(.SelectedItems(lngCount)) & "\" & objFSO.GetBaseName(.SelectedItems(lngCount)) & ".csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close False
Application.ScreenUpdating = True
Next lngCount
End With
Set objFSO = Nothing
Application.ScreenUpdating = True
End Sub