已编写以下脚本以打开文件夹中的所有 .xlsm 文件类型并将它们保存为新目录中的 .xlsx 类型,但尝试另存为 .xlsx 时脚本一直失败。
返回的错误消息是运行时错误“1004”
所有解决此问题的尝试都失败了,非常感谢您的帮助,我提前感谢您。
Set fso = CreateObject("scripting.filesystemobject")
Set fils = fso.GetFolder("FILE LOCATION").Files
FldrPicker = "FILE LOCATION"
With FldrPicker
myPath = FldrPicker
End With
myExtension = "*.xlsm"
myfile = Dir(myPath & myExtension)
filepath = "NEW FILE LOCATION"
Do While myfile <> ""
Set wb = workbooks.Open(Filename:=myPath & myfile)
Application.DisplayAlerts = False
wb.SaveAs = myfile & ".xlsx"
wb.Close Savechanges:=True
Application.DisplayAlerts = True
Loop