使用宏将变量写入文件 [英] Writing variable to a file using macro
本文介绍了使用宏将变量写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将数据从宏写入文本文件.我正在使用以下代码:
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
我有以下问题:
- 文件中的输出包含双引号,即你好,世界""Deployment1.sh"如何消除文本文件中的双引号?
-
有没有一种方法可以比使用一次又一次的写入更好的方式(使用换行符)来写多行?
- The output in my file contains double quotes i.e. "Hello World" "Deployment1.sh" How to get rid of these double quotes in my text file?
Is there a way to write multiple lines in a better way(with new line character) than using Write again and again?
如果我要使用变量,则必须使用变量,例如:"&VarName.在写命令中是否不可能只有VarName.
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.
预先感谢!
推荐答案
用 Print
替换 Write
.
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
这篇关于使用宏将变量写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文