2

I'm trying to send a string variable to command prompt using vba excel. I'm using following code:-

code_name = "xyz.c"
version = "def"
label = "1XDFO"
'open command prompt
    Dim oWsc As Object
    Set oWsc = CreateObject("WScript.Shell")
    Dim oExec As Object
'save config spec in a text file
    Set oExec = oWsc.Exec("perl F:\My_work\hello_world.pl code_name version label")
    While oExec.Status <> 1 ' Wait for process
        Sleep 1000
    Wend

While calling perl script at line "oWsc.Exec("perl F:\My_work\hello_world.pl code_name version label")" i want to send original contents of string variable code_name,version,label; but its sending the variable names as it is and not the content; Can anyone help me with this? Thanks in advance.

1 Answer 1

2

How can an external script (Perl or any other one) understand that what you are sending are variables and read their content? You have to send just the content:

Set oExec = oWsc.Exec("perl F:\My_work\hello_world.pl " & code_name & " " & version & " " & label)

Clarification 1: VBA or .NET or any other Microsoft language, do not "read variables inside strings", like other languages do, PHP for example.

Clarification 2: even a language capable of reading variables inside strings cannot manage what is being done "outside its framework". If you call a PHP script from an external program, you cannot call it as you are doing now because PHP does not have any control on what the external program does and thus on its variables.

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

Comments

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.