通过记事本++打开tsv文件并将其保存为文本格式 [英] Opening tsv file via Notepad++ and save it in text format
本文介绍了通过记事本++打开tsv文件并将其保存为文本格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使一个文件夹中有50多个tsv文件的过程自动化.必须通过记事本++打开它们,并将其另存为.txt文件在同一文件夹中.
I'm trying to automate a process that where in a folder there are 50+ tsv files. They have to be opened via notepad++ and save it as .txt file in the same folder.
使用以下代码,我在记事本++中打开tsv文件.
Using the below code i'm opening the tsv file in notepad++.
MyTxtFile = Shell("C:\Program Files (x86)\Notepad++\notepad++.exe I:\Test\Sample.tsv", 1)
但是,我不知道如何使用VBA将其另存为txt文件.可以吗?如果是的话,请教我如何做.
However, i have no idea how to save it as txt file by using VBA. Is it doable? If yes kindly teach me how.
预先感谢您:)
推荐答案
通过通过数据导出最终找到了解决方法=>从文本"选项可以解决上述问题.
Finally found a remedy by exporting via Data => From Text option the above issue can be tackled..
下面是相同的代码.
Do While fname <> ""
Workbooks.Add
Set wBook = ActiveWorkbook
Set wksht = ActiveSheet
With wksht.QueryTables.Add(Connection:="TEXT;" & folder_name & fname, Destination:=Range("$A$1"))
.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
这篇关于通过记事本++打开tsv文件并将其保存为文本格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文