您好我在处理将 Excel 电子表格转换为 txt 文件时遇到问题。
我想要做的是创建一个宏,它可以将所有 xls 文件放在一个文件夹中并将它们转换为 txt 文件。
目前正在处理的代码
Sub Combined()
Application.DisplayAlerts = False
Const fPath As String = "C:\Users\A9993846\Desktop\"
Dim sh As Worksheet
Dim sName As String
Dim inputString As String
With Application
.Calculation = xlCalculationManual
.EnableEvents = False
.ScreenUpdating = False
End With
sName = Dir(fPath & "*.xls*")
Do Until sName = ""
With GetObject(fPath & sName)
For Each sh In .Worksheets
With sh
.SaveAs Replace(sName, ".xls*", ".txt"), 42 'UPDATE:
End With
Next sh
.Close True
End With
sName = Dir
Loop
With Application
.Calculation = xlAutomatic
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
但它没有按预期工作,我对 VB 的了解为 0。有人愿意伸出援手吗?