2015-01-07 83 views
0

讓說的Excel 2013 VBA加入奇怪報價

Sub test() 
    Worksheets("1").Cells(1, 1).Value = "html" 
    Worksheets("1").Cells(1, 2).Value = "<xml xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" > " 
    txt = "     '" & Worksheets("1").Cells(1, 1) & "'=>array('" & Worksheets("1").Cells(1, 2) & "' => $" & Worksheets("1").Cells(1, 1) & ")," 
    MsgBox txt 
    FilePath = Application.DefaultFilePath & "\array.txt" 
    Open FilePath For Output As #2 
    Write #2, txt 
    Close #2 
End Sub 

現在比較MSGBOX輸出與array.txt文件。

因此,我所有的txt字符串都被引用,還向url添加了額外的引號,如何防止更改並獲取字符串。

問題是如何把msgbox輸出放在array.txt中?

+0

你想要在文本文件中有一個雙引號而不是雙引號? –

+0

請通過添加預期和實際輸出來澄清您的問題。 – RubberDuck

+0

試試'&Chr(34)&'你想在字符串中引號嗎? – Chrismas007

回答

1
Sub test() 
    Worksheets("1").Cells(1, 1).Value = "html" 
    Worksheets("1").Cells(1, 2).Value = "<xml xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" > " 
    txt = "     '" & Worksheets("1").Cells(1, 1) & "'=>array('" & Worksheets("1").Cells(1, 2) & "' => $" & Worksheets("1").Cells(1, 1) & ")," 
    MsgBox txt 
    FilePath = Application.DefaultFilePath & "\array.txt" 
    Open FilePath For Output As #2 
    Print #2, txt 
    Close #2 
End Sub