Consulting

Results 1 to 3 of 3

Thread: Run JavaScript and Get Return

  1. #1
    VBAX Regular
    Joined
    May 2014
    Posts
    71
    Location

    Run JavaScript and Get Return

    I am trying to call the command prompt, execute a java script and have a message displayed upon completion.
    However I am getting a
     Method 'Run' of Object 'IWshShell3' failed
    I can not seem to fix it. Thank you .


    MsgBox ("ImaGene running, please wait")
    
    
    Dim wsh As Object
        Set wsh = VBA.CreateObject("WScript.Shell")
        Dim waitOnReturn As Boolean: waitOnReturn = True
        Dim windowStyle As Integer: windowStyle = 1
    
    
    
    
        wsh.Run "C:\Program Files\BioDiscovery\ImaGene 9.0\ImaGene.exe"" batch " _
                  & XML-*File*-Name, windowStyle, waitOnReturn
    MsgBox ("ImaGene completed")
    I have also tried:

    Shell "C:\Program Files\BioDiscovery\ImaGene 9.0\ImaGene.exe -batch ""C:\Users\cmccabe\Desktop\EmArray\Design\imagene.bch"" /A"
    and that seems to execute the command but there are no results

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,954
    Location
    Seems like you asked this on this forum or another.

    Try to put your string to Run in a variable first. Obviously, your wsh string to run is not the same as the shell string.

    This puts the value of s into the Immediate Window after a run. There are other shellandwait routines but the wsh method should work for you once you get the string to work right. To know if you got it right, after a run, copy that string in the Immediate Window, and then paste it to the Win+R window.

    Sub ken()  Dim s As String
      s = "C:\Program Files\BioDiscovery\ImaGene 9.0\ImaGene.exe -batch ""C:\Users\cmccabe\Desktop\EmArray\Design\imagene.bch"" /A"
      Debug.Print s
      Shell s, vbNormalFocus
      DoEvents
      MsgBox "done"
    End Sub

  3. #3
    VBAX Regular
    Joined
    May 2014
    Posts
    71
    Location
    Thank you .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •