magistercaesar
New Member
- Joined
- Jul 2, 2014
- Messages
- 5
Good morning everyone! First time posting on this forum. Can anyone help me with this code? What it does is it allows me to place a folder path name on column A of a spreadsheet, and then it will look for all of the .xls files and save them as .xlsb. However, I also need it to delete the original .xls file. An edit to the code or even an additional macro that I could run after this would be great appreciated. Thanks all.
Sub Convert_xlsb()
'
'Convert_xlsb Macro
'
'
Dim strPath As String
i = 0
Sub Convert_xlsb()
'
'Convert_xlsb Macro
'
'
Dim strPath As String
Dim strFile, strConvFile As String
Dim wbk As Workbook
Dim i As Integer
Dim Dun As Boolean
i = 0
Dun = False
Do Until Dun
i = i + 1
If ThisWorkbook.Worksheets(1).Cells(i, 1) <> "" Then
' Path must end in trailing backslash
' IE C:\Test\
strPath = ThisWorkbook.Worksheets(1).Cells(i, 1).Value & "\"
strFile = Dir(strPath & "*.xls")
Do While strFile <> ""
If Right(strFile, 3) = "xls" Then
Set wbk = Workbooks.Open(Filename:=strPath & strFile)
strConvFile = Replace(strFile, "xls", "xlsb")
wbk.SaveAs Filename:=strPath & strConvFile, FileFormat:=xlExcel12
wbk.Close SaveChanges:=False
End If
strFile = Dir
Loop
Else
Dun = True
End If
Loop
End Sub