1

How to I automate the conversion of .xls workbooks to .xlsm?

Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
BING
  • 21
  • 1
  • 1
  • 2

1 Answers1

3

You can try this code:

Sub TrandformAllXLSFilesToXLSM()
Dim myPath As String

myPath = "C:\Excel\"
WorkFile = Dir(myPath & "*.xls")

Do While WorkFile <> ""
    If Right(WorkFile, 4) <> "xlsm" Then
        Workbooks.Open FileName:=myPath & WorkFile
        ActiveWorkbook.SaveAs FileName:= _
        myPath & WorkFile & "m", FileFormat:= _
        xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
        ActiveWorkbook.Close
     End If
     WorkFile = Dir()
Loop
End Sub

See this thread for more info

JMax
  • 26,109
  • 12
  • 69
  • 88