+ Reply to Thread
Results 1 to 4 of 4

Using macro to execute a command in Shell Command

  1. #1
    Registered User
    Join Date
    10-14-2010
    Location
    Bonn, Germany
    MS-Off Ver
    Excel 2003
    Posts
    6

    Using macro to execute a command in Shell Command

    Hi All,

    I am trying to execute a command using shell script but I am only able to open files but not execute.

    I tried the following but none of them work code:

    Shell ("cmd /k 'glpsol.exe -m transp.mod'")
    shell ("cmd /c start glpsol.exe -m transp.mod) -- it returns an error stating no file exists

    Can some one help me,
    Last edited by aadarsh; 10-19-2010 at 02:14 PM. Reason: incomplete post

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Using macro to execute a command in Shell Command

    Hi aadarsh,

    As soon as the other program has taken over, Excel code is no longer in control. There are some exceptions to this if the other program is a Micorsoft Office appication and can understand commands comming from Excel.

    I've found the best I can do is to use "SendKeys" throught the keyboard buffer using Excel and hope it makes it to the other program.

    I hope this helps. Perhaps someone else has a suggestion?

  3. #3
    Registered User
    Join Date
    10-14-2010
    Location
    Bonn, Germany
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Using macro to execute a command in Shell Command

    Hey I think i figured out.

    the command:

    Shell ("cmd.exe /K glpsol.exe -m umbrellas.mod -d LP.dat")
    works fine. But it works only when I have the .exe file and other files in the default folder.

    Any ideas how I can go to the right folder in the cmd environment using a macro

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Using macro to execute a command in Shell Command

    I was talking with a Microsoft employee a few weeks ago and they were telling me how great the new Windows 7 PowerShell was. It is an upgrade to the old DOS Cmd command. I know very little about it but I wonder if it would allow what you are trying to do.

    I'm off to learn more about PowerShell. I was surprised it lived on my computer (windows 7) and I didn't have to download or install it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1