Way to convert from .xls to .xlsm via a batch file or vba?

孤街浪徒 提交于 2019-12-13 03:51:40

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/7167207/way-to-convert-from-xls-to-xlsm-via-a-batch-file-or-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!