I need to write data from a macro to a text file. I am using the below code:
VAR_ABC = "Deployment1.txt"
Dim FlName As String
filesize = FreeFile()
Open FlName For Output As #filesize
Write #filesize, "Hello World!"
Write #filesize, "" & VAR_ABC;
Close #filesize
I have below questions:
Is there a way to write multiple lines in a better way(with new line character) than using Write again and again?
If I am to use variables, is it mandatory to use them like: "" & VarName. Is it not possible to have only VarName in Write Command.
Thanks in Advance!
答案 0 :(得分:0)
Replace Write
with Print
.
Sub test()
VAR_ABC = "Deployment1.txt"
Dim FlName As String
filesize = FreeFile()
Open "C:\Temp\Hello.txt" For Output As #filesize
Print #filesize, "Hello World!"
Print #filesize, VAR_ABC;
Close #filesize
End Sub