Excel VBA将文本另存为' .fcf'文件扩展名

时间:2015-09-25 13:35:31

标签: excel vba excel-vba

我已将此代码保存到excel表格中的文本。

我需要对此进行调整,以将.txt文件另存为.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"

1 个答案:

答案 0 :(得分:2)

您是否尝试更改通话中的文件名?

SaveColumn "Output to fcf.1", "A", "P:\4_Calcs\02. Flag Mapping\test_.fcf"