2

I am working on VBA, from which I have to call a vbscript by passing some values.

Here is the code:

''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

Now, when I running the code, it is passing below values properly to vbscript:

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

It is having issues with these:

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

Now, wierd thing for me is, if I keep a cell empty for "testPathALM" which is having "Subject\xyz - Use it!\xyz_abc" as value, I am getting "QCurl" value properly in vbscript.

But, if I keep value "Subject\xyz - Use it!\xyz_abc" for "testPathALM", then I am getting "-" for strServer which suppose to be "QCurl" value and "Subject\xyz" for "strRootNode" which supposed to be "Subject\xyz - Use it!\xyz_abc".

I am unable to understand what is the issue here.

Thanks a ton in advance.

1 Answer 1

5

Safer to quote all of your parameters:

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

Try a debug.print to make sure it looks as it should...

Sign up to request clarification or add additional context in comments.

1 Comment

+ 1 you beat me to it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.