Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Nov 2001
    Location
    Fort Dodge, Iowa, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sendkeys('someString') -> CMD.exe (Excel '97 VBA)

    I'm trying to get a function in Excel '97 VBA to send commands to an open DOS window. I want to end up with a function that can either ask for - or have passed to it - the user's name, password, the mainframe file they want, and what they want to call it locally. To do _that_, however, I first need to be able to send text to a DOS window - programmatically - from within Excel.

    Any ideas? The Sendkeys F(x) help file isn't all that...umm...helpful.

    Thanks much,

    malkor

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sendkeys('someString') -> CMD.exe (Excel '97 VBA)

    A little more info here. What's the final objective? Start a file transfer? A host session?

    Is the objective command line driven?

    Just guessing, one way to do this is create a batch file that takes 3 parameters: name, pass and filename. You get the values for those via an Excel control, etc. then

    Shell( "FireTheApp.bat uname upass fname")

    ...start the DOS session and the processing in one swoop. If you really want to poke text onto a DOS command line in a DOS "box", you'll probably have to use the API to do it.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Lounger
    Join Date
    Nov 2001
    Location
    Fort Dodge, Iowa, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sendkeys -> CMD.exe (Clarification)

    First, the final objectve - sorry if I was too brief - is to end up with a VBA function which can do the work of FTP'ing a file _either_ to or from a given host.

    Second, _which_ API are you talking about at the end if your post? I'm not yet familiar with many API functions.

    Thanks much.

    malkor

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sendkeys -> CMD.exe (Clarification)

    I was thinking of SendMessage.

    But is sounds like a simple batch file would do the trick. You can even create the batch file in Excel, execute it, then delete it so you don't have to worry about a user accidentally deleting a necessary file.

    Post the syntax for your FTP command line.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Sendkeys('someString') -> CMD.exe (Excel '97 VBA)

    malkor

    Stay away from <font color=red> Sendkeys </font color=red> . Sendkeys is a bad way to control things and should be used only as a <font color=red> last resort </font color=red>

    How about using the shell command, or better yet, if you care in knowing when the application terminates you can use the MSKB code that I can send to you.

    Check the Shell command and see if it will work for you, and then if you need more help, well all you need to do is send a reply to this message <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

Posting Permissions

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