'将 工程-部件-控件-Microsoft Common Dialog Control 6.0(SP3)选中
Private Sub Command1_Click()
Dim R As String, L As String
CommonDialog1.InitDir = App.Path
CommonDialog1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen '显示打开文件对话框
R = CommonDialog1.FileName
CommonDialog1.InitDir = App.Path
CommonDialog1.Filter = "文本文件(*.CSV)|*.CSV|所有文件(*.*)|*.*"
If UCase(Right(R, 4)) = ".TXT" Then
L = Left(R, Len(R) - 4) & ".CSV"
Else
L = R & ".CSV"
End If
CommonDialog1.FileName = L
CommonDialog1.ShowSave '显示打开文件对话框
L = CommonDialog1.FileName
Print R & "保存为" & L
If UCase(Right(L, 4)) = ".TXT" Then
L = Left(L, Len(L) - 4) & ".CSV"
Else
L = L ' & ".CSV"
End If
FileCopy R, L
End Sub
直接保存为CSV文件即可,或者用VB改名
Dim fs, file1, file2
Set fs = CreateObject( "Scripting.FileSystemObject ")
file1 = "sourcefilename " '原文件名
file2 = "destfilename " '要改成的文件名
fs.MoveFile file1, file2
还可以直接用name
name oldfilename as newfilename
至于路径没有看懂什么意思,是CSV的文件路径,还是CSV内容里面的路径?
其实不管什么路径,都可以用变量来设置。