excel批量转换成txt文本文
Sub 按钮1_单击()
Application。DisplayAlerts = False
Application。ScreenUpdating = False
mypath = ThisWorkbook。 Path & "\xls文件\"
mypathtxt = ThisWorkbook。Path & "\txt文件\"
myfilename = Dir(mypath & "*。 xls")
Do While (Len(myfilename) > 0)
Set mybk = GetObject(mypath & myfilename)
For Each sh In mybk。 S...全部
Sub 按钮1_单击()
Application。DisplayAlerts = False
Application。ScreenUpdating = False
mypath = ThisWorkbook。
Path & "\xls文件\"
mypathtxt = ThisWorkbook。Path & "\txt文件\"
myfilename = Dir(mypath & "*。
xls")
Do While (Len(myfilename) > 0)
Set mybk = GetObject(mypath & myfilename)
For Each sh In mybk。
Sheets
sh。Activate
sh。Columns(2)。NumberFormatLocal = "@"
sh。
Copy
ActiveWorkbook。SaveAs Filename:=mypathtxt & ActiveSheet。Name & "。txt", FileFormat:=xlUnicodeText
ActiveWorkbook。
Close
Next
mybk。Close
myfilename = Dir()
Loop
Set mybk = Nothing
Application。
DisplayAlerts = True
Application。ScreenUpdating = True
End Sub
excel文件放在xls文件夹,
生成的结果放在txt文件夹中的。
Unicode编码包括ASCII吧。
这样的直接保存不知,符不符要求。
不符合格式要求,明天就改为直接写入到TXT文件中。
。收起