从VBA到VBScript的variables

我正在使用VBA,我必须通过传递一些值来调用vbscript。

这里是代码:

''VBA 'Below values are on different cells of Excel file which I am reading 'into a global variable then pass it to vbscript. 'SFilename = VBscript file path 'QClogin = "abc" 'QCpassword = "abc" 'sDomain = "xyz" 'sProject = "xyz123" 'testPathALM = "Subject\xyz - Use it!\xyz_abc" 'QCurl = "http://xxx_yyy_zzz/qcbin/" Set wshShell = CreateObject("Wscript.Shell") Set proc = wshShell.exec("wscript " & SFilename & " " & QClogin & _ " " & "" & QCpassword & " " & "" & sDomain & " " & "" & sProject & _ " " & "" & testPathALM & " " & "" & QCurl & "") ''VBscript on some location Dim strUserName, strPassword, strServer strUserName = WScript.Arguments(0) '"abc" Msgbox "strUserName : " & strUserName strPassword = WScript.Arguments(1) '"abc" Msgbox "strPassword : " & strPassword strServer = WScript.Arguments(5) '"http://xxx_yyy_zzz/qcbin/" Msgbox "strServer : " & strServer Dim strDomain, strProject, strRootNode strDomain = WScript.Arguments(2) '"xyz" Msgbox "strDomain: " & strDomain strProject = WScript.Arguments(3) '"xyz123" Msgbox "strProject: " & strProject strRootNode = WScript.Arguments(4) '"Subject\xyz - Use it!\xyz_abc" Msgbox "strRootNode: " & strRootNode 

现在,当我运行代码时,正确地将下面的值传递给vbscript:

 QClogin = "abc" QCpassword = "abc" sDomain = "xyz" sProject = "xyz123" 

这是有这些问题:

 testPathALM = "Subject\xyz - Use it!\xyz_abc" QCurl = "http://xxx_yyy_zzz/qcbin/" 

现在,对我来说更奇怪的是,如果我将 testPathALM”中的“Subject \ xyz – Use it!\ xyz_abc”作为值的单元格保留为空,我将在vbscript中正确获得“QCurl”值。

但是,如果我保留“Subject \ xyz – 使用它!\ xyz_abc”作为“testPathALM”的值,那么我将strServer的 “ – ”replace“QCurl”的值, “Subject \ xyz ”replace“strRootNode”应该是“Subject \ xyz – 使用它!\ xyz_abc”

我无法理解这里有什么问题。

预先感谢一吨。

更安全地引用您的所有参数:

 Set wshShell = CreateObject("Wscript.Shell") Set proc = wshShell.exec("wscript """ & SFilename & """ """ & _ QClogin & """ """ & QCpassword & """ """ & _ sDomain & """ """ & sProject & """ """ & _ testPathALM & """ """ & QCurl & """") 

尝试debug.print,以确保它看起来应该…