Excel VBA将文本另存为“.fcf”文件扩展名
我有这个代码来保存从Excel表格文本到.txt文件。
我需要适应这个将.txt
文件保存为.fcf
文件
目前我通过保存文本文件,然后手动将其重命名为test.fcf
解决此test.fcf
。 有没有可能在VBA中重命名? 或直接保存到.fcf
?
Sub SaveColumn(sheetName As String, columnName As String, fileName As String) Dim cell Dim fso Dim file Set fso = CreateObject("Scripting.FileSystemObject") Set file = fso.CreateTextFile(fileName, True) For Each cell In Sheets(sheetName).Columns(columnName).Cells If cell.Value <> "" Then file.WriteLine cell.Value End If Next file.Close Set file = Nothing Set fso = Nothing End Sub To call it... SaveColumn "Output to fcf.1", "A", "P:\4_Calcs\02. Flag Mapping\test_.txt"
您是否尝试更改通话中的文件名?
SaveColumn "Output to fcf.1", "A", "P:\4_Calcs\02. Flag Mapping\test_.fcf"