+ Reply to Thread
Results 1 to 11 of 11

SendKeys

  1. #1
    Registered User
    Join Date
    01-28-2011
    Location
    Sydney Australia
    MS-Off Ver
    Excel 2000
    Posts
    13

    SendKeys

    Hi

    From Excel I want to activate another window and then send some keystrokes to that window.

    From the code below:
    1) the window "destination.txt" ALWAYS comes into focus reliably (becomes active) - this does not seem to be a problem.
    2) the sent keystrokes are VERY intermittent - sometimes they arrive but mostly nothing goes to the "destination.txt" window.

    Please Login or Register  to view this content.
    Any suggestions??
    Last edited by pvj; 02-04-2011 at 08:30 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Please help with "SendKeys"

    If you just want to write to a text file you don't need to use sendkeys.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    01-28-2011
    Location
    Sydney Australia
    MS-Off Ver
    Excel 2000
    Posts
    13

    Re: Please help with "SendKeys"

    The code above is just a test.

    What I really need to do is:
    1) crunch some conditions in excel
    2) bring another program's window into focus
    3) send 'alt'+'b' to that other program - which will then perform another task

    Right now I'm just trying to get the code to work.

    Thanks for any help

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Please help with "SendKeys"

    I know it's sometimes worth adding pauses to your code when using sendkeys. I've never really used them much though I have to admit.

    Dom

  5. #5
    Registered User
    Join Date
    01-28-2011
    Location
    Sydney Australia
    MS-Off Ver
    Excel 2000
    Posts
    13

    Re: Please help with "SendKeys"

    I had thought of that - but I can't find any commands/syntax for pause / sleep / wait etc

    how do you introduce a pause into the code???

    Thank you for your help

  6. #6
    Registered User
    Join Date
    01-28-2011
    Location
    Sydney Australia
    MS-Off Ver
    Excel 2000
    Posts
    13

    Re: Please help with "SendKeys"

    I had thought of that - but I can't find any commands/syntax for pause / sleep / wait etc

    how do you introduce a pause into the code???

    Thank you for your help

  7. #7
    Registered User
    Join Date
    01-28-2011
    Location
    Sydney Australia
    MS-Off Ver
    Excel 2000
    Posts
    13

    Re: Please help with "SendKeys"

    I had thought of that - but I can't find any commands/syntax for pause / sleep / wait etc

    how do you introduce a pause into the code???

    Thank you for your help

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Please help with "SendKeys"

    This will pause for a second:

    Please Login or Register  to view this content.

    Dom

  9. #9
    Registered User
    Join Date
    01-28-2011
    Location
    Sydney Australia
    MS-Off Ver
    Excel 2000
    Posts
    13

    Re: Please help with "SendKeys"

    Thankyou - that seems to work very well.

    I'm sorry to say that I missed that command in the help.

    Do you know of a way to pause for less than a second???
    The 'timer' function (according to the help) does fractions of a second but the help doesn't give an example of less than a second.

    Thankyou for your help.

  10. #10
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Please help with "SendKeys"

    I think you can use a Sleep API to pause for less than a second.

    Pop this at the top of your module:

    Please Login or Register  to view this content.

    and then you can use it like this where 1 second = 1000:

    Please Login or Register  to view this content.

    Dom

  11. #11
    Registered User
    Join Date
    01-28-2011
    Location
    Sydney Australia
    MS-Off Ver
    Excel 2000
    Posts
    13

    Re: Please help with "SendKeys"

    Perfect - it works great.

    Thank you for your help

    Now I can solve the real problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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