2012-03-07 78 views
2

在我的代碼小區C18是文件路徑VBA打印和寫入命令混亂

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文件,但在變量所包含的內容中包含「」?

我試過寫#1命令,但它只是放「模板」,這不是我想要的。

它不會讓我寫單」,例如這將是確定的:

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

但它總是其校正成

Write #1, "" 
+0

我想我可以去 – 2012-03-07 12:28:04

回答

2

要打印"翻倍了,直到""所以;

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