+ Reply to Thread
Results 1 to 8 of 8

Sendkeys doesn't work on my laptop with Vista

Hybrid View

  1. #1
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Sendkeys doesn't work on my laptop with Vista

    I have a workbook that I transfer back and forth from my desktop to my laptop, that uses Sendkeys to add code to the active pane in VBA. It doesn't work on my laptop, but works fine on my desktop.

    Both computers have Vista. Is there a switch somewhere to make Sendkeys work?
    Last edited by foxguy; 01-26-2010 at 07:25 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: Sendkeys doesn't work on my laptop with Vista

    Is this just to save typing, as a matter of interest?
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Sendkeys doesn't work on my laptop with Vista

    Yes, primarily from having to type the same stuff over & over.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Sendkeys doesn't work on my laptop with Vista

    Hello foxguy,

    SendKeys under Vista seems to be problematic, especially when run in the VBIDE. Your best option is to use an API code replacement for SendKeys. I would need to see samples of the data you're sending before I could offer the best solution.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Sendkeys doesn't work on my laptop with Vista

    Leith;
    It's news to me that SendKeys under Vista is problematic, but it explains my problem.
    I have 2 situations. The 1st I can fix by using the codemodule methods, but the 2nd stumps me.
    Sub SomeSub()
        .... codelines
        MyStop
        .... more codelines
    End Sub
    
    Sub MyStop()
        If IsDeveloper() then
            Application.Sendkeys "+^{F8}"                'Step Out (back to calling procedure)
            Stop
        End If
    End Sub
    This lets me put in just one word "MyStop" in my code that stops and positions my cursor on the next line after MyStop, and I don't have to worry about accidentally leaving it in the finished product, because IsDeveloper() never returns TRUE except on my computer.
    This works fine on my desktop, but on my laptop, it stops inside MyStop and I have to manually click on "Step Out". Just irritating, and I would rather not live with it.

    Any ideas on how I can make this work the way I want?

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: Sendkeys doesn't work on my laptop with Vista

    What's wrong with breakpoints or Run to Cursor? Either would be better than adding unneeded code to a project, IMO.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: Sendkeys doesn't work on my laptop with Vista

    In fact, if IsDeveloper is only true on your machine, why not just use a:
    Debug.Assert Not IsDeveloper()
    statement?

  8. #8
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Sendkeys doesn't work on my laptop with Vista

    Romperstomper;
    I admit, I forgot all about Assert. It accomplishes the same thing, just more typing.

    My sub is actually named MS(), so that I only have to type 2 letters to put in a conditional stop. I hate typing in the same code over & over, which is why I developed the subs that insert code into the codepanes in the first place.

    It looks like I'll developer a sub that inserts "Debug.Assert IsDeveloper()" into my code. I'll just have to get used to hitting a menu button instead of typing "MS".

+ 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