Hello,
I've been using this macro for months without issue but today I keep getting the same error. What the macro is doing is opening csv files and saving them as xlsx files. I have highlighted in Blue where the error occurs. I'm not sure how to fix... any help/guidance is much appreciated. Thanks everyone!
' Saves csv files as xls files
'
'
Public Sub csvToxls()
Dim FSO As Object
Dim folder As Object
Dim wb As Object
csvPath = "C:\Users\vitdom01\OneDrive\Desktop\ENVIRONMENT LIST\csv"
xlsPath = "C:\Users\vitdom01\OneDrive\Desktop\ENVIRONMENT LIST\xls"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set csvFolder = FSO.GetFolder(csvPath)
If FSO.FolderExists(xlsPath) = False Then
FSO.createFolder (xlsPath)
End If
Set xlsFolder = FSO.GetFolder(xlsPath)
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
For Each wb In csvFolder.Files
If LCase(Right(wb.Name, 3)) = "csv" Then
Set activeWB = Workbooks.Open(wb)
activeWB.SaveAs Filename:=xlsPath & "" & Left(activeWB.Name, Len(activeWB.Name) - 3) & "xlsx", FileFormat:=xlOpenXMLWorkbook
activeWB.Close True
End If
Next
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
' Mark as Complete
'
'
Range("E5").Select
ActiveCell.FormulaR1C1 = "Complete"
Range("E5").Select
Selection.Font.Bold = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 12611584
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Range("E5").Select
End Sub
I've been using this macro for months without issue but today I keep getting the same error. What the macro is doing is opening csv files and saving them as xlsx files. I have highlighted in Blue where the error occurs. I'm not sure how to fix... any help/guidance is much appreciated. Thanks everyone!
' Saves csv files as xls files
'
'
Public Sub csvToxls()
Dim FSO As Object
Dim folder As Object
Dim wb As Object
csvPath = "C:\Users\vitdom01\OneDrive\Desktop\ENVIRONMENT LIST\csv"
xlsPath = "C:\Users\vitdom01\OneDrive\Desktop\ENVIRONMENT LIST\xls"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set csvFolder = FSO.GetFolder(csvPath)
If FSO.FolderExists(xlsPath) = False Then
FSO.createFolder (xlsPath)
End If
Set xlsFolder = FSO.GetFolder(xlsPath)
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
For Each wb In csvFolder.Files
If LCase(Right(wb.Name, 3)) = "csv" Then
Set activeWB = Workbooks.Open(wb)
activeWB.SaveAs Filename:=xlsPath & "" & Left(activeWB.Name, Len(activeWB.Name) - 3) & "xlsx", FileFormat:=xlOpenXMLWorkbook
activeWB.Close True
End If
Next
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
' Mark as Complete
'
'
Range("E5").Select
ActiveCell.FormulaR1C1 = "Complete"
Range("E5").Select
Selection.Font.Bold = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 12611584
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Range("E5").Select
End Sub
Last edited: