我真的想更改此代码的目录,Application.ActiveWorkbook.Path
但我不知道将其放置在哪里。
Public Sub CharacterSV()
Const DELIMITER As String = "|"
Dim myRecord As Range
Dim myField As Range
Dim nFileNum As Long
Dim sOut As String
nFileNum = FreeFile
Open ActiveWorkbook.Name & ".txt" For Output As #nFileNum
For Each myRecord In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
With myRecord
For Each myField In Range(.Cells, _
Cells(.Row, Columns.Count).End(xlToLeft))
sOut = sOut & DELIMITER & myField.Text
Next myField
Print #nFileNum, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
Close #nFileNum
End Sub
我试图弄清楚它,真的很想学习VBA,但我无法使其正常工作。
提前致谢!