2
我正在使用VBA,我必須通過傳遞一些值來調用vbscript。從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」這是有「主題\ xyz - 使用它!\ xyz_abc」作爲值,我得到「QCurl」值在VBScript中正確。
但是,如果我堅持價值「主題\ XYZ - 使用它\ xyz_abc!」爲「testPathALM」,然後我得到「 - 」爲strServer其假設是「QCurl 「價值和」「 爲 」strRootNode「這應該是」主題\某某主題\ XYZ - 用它\ xyz_abc「!
我無法理解這裏有什麼問題。
感謝提前一噸。
+ 1,你打我吧:) –
感謝很多@Tim,你是生命的救星......我不知道我是怎麼錯過的...... – ManishChristian
謝謝@Siddharth ... – ManishChristian