【问题标题】:VBA Print and Write command confusionVBA 打印和写入命令混淆
【发布时间】:2012-03-24 23:31:09
【问题描述】:

在我的代码的单元格 C18 中是文件路径

C:\blahblahblah\yay.db

我想写一个 txt 文件,所以第一行是:

uil_file_new.go( "C:\blahblahblah\yay.db","C:\blahblahblah\yay.db")

我尝试了以下方法:

Dim template As String
template = Range("C18").Value

Open (ThisWorkbook.Path & "\" & "test.txt") For Output Access Write Shared as #1
Print #1, "uil_file_new.go( " & template & "," & template & ")"
Close #1

这给了

uil_file_new.go( C:\blahblahblah\yay.db ,C:\blahblahblah\yay.db)

我需要 txt 文件在文件路径周围有“”。有没有办法将变量传递给 txt 文件,但在变量包含的内容周围有“”?

我尝试了 Write #1, 命令,但它只是放置“模板”,这不是我想要的。

它不会让我写一个“,例如这样就可以了:

Write #1, "
Print #1, template
Write #1, "

但它总是将其更正为

Write #1, ""

【问题讨论】:

    标签: vba printing


    【解决方案1】:

    要打印" 将它们加倍到"" 所以;

    Print #1, "uil_file_new.go(""" & template & """,""" & template & """)"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多