0
我发现这里一个脚本,将每个工作表导出文件为.csv文件此导出宏,但我需要调整它导出表为文本制表符分隔的文件,而不是。我试图修改它,但它只是以不带分隔符的文本输出。这里是原代码:需要修改文本制表符分隔输出
Public Sub DoTheExport()
Dim FName As Variant
Dim Sep As String
Dim wsSheet As Worksheet
Dim nFileNum As Integer
Dim csvPath As String
Sep = InputBox("Enter a single delimiter character (e.g., comma or semi-colon)", _
"Export To Text File")
'csvPath = InputBox("Enter the full path to export CSV files to: ")
csvPath = GetFolderName("Choose the folder to export CSV files to:")
If csvPath = "" Then
MsgBox ("You didn't choose an export directory. Nothing will be exported.")
Exit Sub
End If
For Each wsSheet In Worksheets
wsSheet.Activate
nFileNum = FreeFile
Open csvPath & "\" & _
wsSheet.Name & ".csv" For Output As #nFileNum
ExportToTextFile CStr(nFileNum), Sep, False
Close nFileNum
Next wsSheet
End Sub
,这里是我怎么也得修改了它:提前
Public Sub DoTheExport()
Dim FName As Variant
Dim Sep As String
Dim wsSheet As Worksheet
Dim nFileNum As Integer
Dim txtPath As String
'Sep = InputBox("Enter a single delimiter character (e.g., comma or semi-colon)", _
'"Export To Text File")
'csvPath = InputBox("Enter the full path to export CSV files to: ")
txtPath = GetFolderName("Choose the folder to export TXT files to:")
If txtPath = "" Then
MsgBox ("You didn't choose an export directory. Nothing will be exported.")
Exit Sub
End If
For Each wsSheet In Worksheets
wsSheet.Activate
nFileNum = FreeFile
Open txtPath & "\" & _
wsSheet.Name & ".txt" For Output As #nFileNum
ExportToTextFile CStr(nFileNum), Sep, False
Close nFileNum
Next wsSheet
End Sub
谢谢!
太棒了!完美的作品!谢谢!! – user955289 2012-03-21 14:19:31