Announcement

Collapse
No announcement yet.

Call .exe From VBA

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Call .exe From VBA



    I want to run an .exe program from Excel, so I used the shell method. This program should read in some input in text format. However, when I call from Excel, the prgram cannot read the input. When I run the program alone, it is OK.
    Can anyone tell me what is wrong?

  • #2
    Re: Error In Call .exe Program From Vba

    Is the exe receiving the proper command string from the shell statement?
    Entia non sunt multiplicanda sine necessitate.

    Comment


    • #3
      Re: Error In Call .exe Program From Vba

      this is what I write in Vba,

      Code:
      RetVal = Shell("E:\project\test.exe", 1)
      test.exe will need read data from "input.txt" in the same directory as the exe file. but when i call test.exe from VBA by this Shell command, the test.exe can't read the data from input.txt, it still can run but will display nothing. If directly run text.exe, it will display the data from input.txt.
      Last edited by Dave Hawley; January 1st, 2008, 11:38.

      Comment


      • #4
        Re: Error In Call .exe Program From Vba

        test.exe requires no arguments? Does it depend on the current directory being correct?
        Entia non sunt multiplicanda sine necessitate.

        Comment


        • #5
          Re: Error In Call .exe Program From Vba

          no. It will retrieve information from input.txt. But seems when using shell command to invoke the test.exe....test.exe couldn't recoganize input.txt.

          the actually project is.
          1st..VBA processing Excel file and output a few .csv files, these .csv files will be used as the input data of step 2 processingdata.exe program. ( the processingdata.exe is written in C++, because i am not very familar with VBA. so I put my main logic input this .exe to process data)
          2nd...VBA will using Shell command line to invoke processingdata.exe, and the .exe will output another .csv file
          3rd...VBA will copy the data from .csv generated in step 2. and update the Excel file

          So the problem now is that,,,in the 2nd step, when invoke .exe file..it can't read data from the .csv files..seems all the .csv files are empty for it.
          what i think is that: this line-----RetVal = Shell("E:\project\processingdata.exe", 1)
          only pass one argument to Shell. which is "E:\project\processingdata.exe", without the path and name of all the .csv input files.
          Is there anyway i can add in?

          Comment


          • #6
            Re: Error In Call .exe Program From Vba

            Put the whole run string inside the quotes.
            Entia non sunt multiplicanda sine necessitate.

            Comment


            • #7


              Re: Error In Call .exe Program From Vba

              musecat, please use Code Tags for ALL code.

              Comment

              Working...
              X