通过Notepad++打开tsv文件并保存为文本格式
Opening tsv file via Notepad++ and save it in text format
我正在尝试自动化一个文件夹中有 50 多个 tsv 文件的过程。它们必须通过记事本++打开并将其保存为同一文件夹中的.txt文件。
我使用下面的代码在记事本++中打开 tsv 文件。
MyTxtFile = Shell("C:\Program Files (x86)\Notepad++\notepad++.exe I:\Test\Sample.tsv", 1)
但是,我不知道如何使用 VBA 将它保存为 txt 文件。可行吗?如果是,请教我怎么做。
提前谢谢你:)
如果您只想将文件从 *.tsv 重命名为 *.txt,您可以使用命令行
ren *.tsv *.txt
还有另一个线程涉及调用 shell 命令的一般方面。或许对你有帮助:
Execute a command in command prompt using excel VBA
终于找到了通过数据导出的补救方法 => 从文本选项可以解决上述问题..
下面是相同的代码..
Do While fname <> ""
Workbooks.Add
Set wBook = ActiveWorkbook
Set wksht = ActiveSheet
With wksht.QueryTables.Add(Connection:="TEXT;" & folder_name & fname, Destination:=Range("$A"))
.Name = fname
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 65001
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
我正在尝试自动化一个文件夹中有 50 多个 tsv 文件的过程。它们必须通过记事本++打开并将其保存为同一文件夹中的.txt文件。
我使用下面的代码在记事本++中打开 tsv 文件。
MyTxtFile = Shell("C:\Program Files (x86)\Notepad++\notepad++.exe I:\Test\Sample.tsv", 1)
但是,我不知道如何使用 VBA 将它保存为 txt 文件。可行吗?如果是,请教我怎么做。
提前谢谢你:)
如果您只想将文件从 *.tsv 重命名为 *.txt,您可以使用命令行
ren *.tsv *.txt
还有另一个线程涉及调用 shell 命令的一般方面。或许对你有帮助: Execute a command in command prompt using excel VBA
终于找到了通过数据导出的补救方法 => 从文本选项可以解决上述问题..
下面是相同的代码..
Do While fname <> ""
Workbooks.Add
Set wBook = ActiveWorkbook
Set wksht = ActiveSheet
With wksht.QueryTables.Add(Connection:="TEXT;" & folder_name & fname, Destination:=Range("$A"))
.Name = fname
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 65001
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With