从VBA到VBScript的变量
我正在使用VBA,从中我必须通过传递一些值来调用vbscript 代码如下:从VBA到VBScript的变量,vba,excel,vbscript,Vba,Excel,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
''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-使用它!\xyz_abc”作为值,我将在vbscript中正确地获得“QCurl”值
但是,如果我为“testPathALM”保留值“Subject\xyz-使用它!\xyz_abc”,那么我将为strServer获得“-”,该值假设为“QCurl”值,而为“strRootNode”获得“主题\xyz-使用它\xyz_abc“
我无法理解这里的问题是什么
提前感谢您。更安全地引用您的所有参数:
Set wshShell = CreateObject("Wscript.Shell")
Set proc = wshShell.exec("wscript """ & SFilename & """ """ & _
QClogin & """ """ & QCpassword & """ """ & _
sDomain & """ """ & sProject & """ """ & _
testPathALM & """ """ & QCurl & """")
尝试debug.print以确保它看起来像它应该的那样…+1你比我快:)