Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 7 of 7

Thread: Call .exe From VBA

  1. #1
    Join Date
    1st January 2008
    Posts
    3

    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?

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    12th September 2006
    Location
    The Great State of Texas
    Posts
    4,322

    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.
    MS MVP - Excel

  3. #3
    Join Date
    1st January 2008
    Posts
    3

    Re: Error In Call .exe Program From Vba

    this is what I write in Vba,

    VB:
    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 at 10:38.

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    12th September 2006
    Location
    The Great State of Texas
    Posts
    4,322

    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.
    MS MVP - Excel

  5. #5
    Join Date
    1st January 2008
    Posts
    3

    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?

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    12th September 2006
    Location
    The Great State of Texas
    Posts
    4,322

    Re: Error In Call .exe Program From Vba

    Put the whole run string inside the quotes.
    Entia non sunt multiplicanda sine necessitate.
    MS MVP - Excel

  7. #7
    Join Date
    24th January 2003
    Location
    Australia
    Posts
    31,696

    Re: Error In Call .exe Program From Vba

    musecat, please use Code Tags for ALL code.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Call a Sub Procedure from Another
    By Furion in forum EXCEL HELP
    Replies: 5
    Last Post: June 19th, 2008, 10:13
  2. #REF with VBA Function Call
    By TonyO in forum EXCEL HELP
    Replies: 1
    Last Post: January 12th, 2006, 04:54
  3. VBA Call function
    By brenny in forum EXCEL HELP
    Replies: 7
    Last Post: July 29th, 2005, 07:44
  4. DLL call from VBA
    By newVBAuser in forum EXCEL HELP
    Replies: 4
    Last Post: January 19th, 2005, 23:34
  5. call sub
    By REP013 in forum EXCEL HELP
    Replies: 2
    Last Post: October 19th, 2004, 19:54

Bookmarks

Posting Permissions

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