Results 1 to 11 of 11

Thread: Sendkeys

  1. #1
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Unanswered: Sendkeys

    Aarrghh...What is the sendkeys command to send Ctrl-V so I can paste an image?
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I have a sneaky suspicion the ^ is ctrl. I will check....

    Went for quick rather than accurate posting since you seem frustrated - please be gentle on me if I missed the boat by a long way
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Code:
    SendKeys "^(V)", False
    ????
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Sorry about the frustation Pootle but I've answered so many questions on this board and now need a little help but I haven't gotten any replies (except yours - thank you very much). I tried using the command you supplied but it still won't work - thus my frustration. I know there's an easy way to do this and that's what's frustrating me. Someone on this board has to know the command to copy from the clipboard. Could someone PLEASE send me some suggestions to try?
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Paste

    Pootle,

    Thank you again for your answer. I found the command (after trying several, several different variations and a lot of searching). The command which finally worked is:

    SendKeys ("^v") 'Paste


    Seemed so easy yet so hard to find. Again, Thank you for responding! I was a little dissappointed though in that I didn't get any other responses as I've tried to respond to soo many posts on this board.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    It's only been two hours... on a work day...

    For what it's worth, here's a handy way to copy stuff TO the clipboard without using sendkeys, assuming the source data is coming from Access:

    Code:
    Option Compare Database
    
    Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) _
       As Long
    Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) _
       As Long
    Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _
       ByVal dwBytes As Long) As Long
    Declare Function CloseClipboard Lib "User32" () As Long
    Declare Function OpenClipboard Lib "User32" (ByVal hwnd As Long) _
       As Long
    Declare Function EmptyClipboard Lib "User32" () As Long
    Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, _
       ByVal lpString2 As Any) As Long
    Declare Function SetClipboardData Lib "User32" (ByVal wFormat _
       As Long, ByVal hMem As Long) As Long
    
    Public Const GHND = &H42
    Public Const CF_TEXT = 1
    Public Const MAXSIZE = 4096
    
    Function ClipBoard_SetData(MyString As String)
       Dim hGlobalMemory As Long, lpGlobalMemory As Long
       Dim hClipMemory As Long, X As Long
    
       ' Allocate moveable global memory.
       '-------------------------------------------
       hGlobalMemory = GlobalAlloc(GHND, Len(MyString) + 1)
    
       ' Lock the block to get a far pointer
       ' to this memory.
       lpGlobalMemory = GlobalLock(hGlobalMemory)
    
       ' Copy the string to this global memory.
       lpGlobalMemory = lstrcpy(lpGlobalMemory, MyString)
    
       ' Unlock the memory.
       If GlobalUnlock(hGlobalMemory) <> 0 Then
          MsgBox "Could not unlock memory location. Copy aborted."
          GoTo OutOfHere2
       End If
    
       ' Open the Clipboard to copy data to.
       If OpenClipboard(0&) = 0 Then
          MsgBox "Could not open the Clipboard. Copy aborted."
          Exit Function
       End If
    
       ' Clear the Clipboard.
       X = EmptyClipboard()
    
       ' Copy the data to the Clipboard.
       hClipMemory = SetClipboardData(CF_TEXT, hGlobalMemory)
    
    OutOfHere2:
    
       If CloseClipboard() = 0 Then
          MsgBox "Could not close Clipboard."
       End If
    
       End Function
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thanks Teddy. I was just a little impatient as my initial other post wasn't answered at all (after a couple of days of waiting) and I kind of felt like no one wanted to answer it (again - call it being impatience). This is the 2nd time I've posted the same type of question and I appreciate your response.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Paul, I actually spent over an hour trying to find a way to make the #!@# thing work, with no luck. I've been out and just came back, and I still can't make SendKeys ("^v") 'Paste work! Ugh! I've only used them once or twice before, when absolutely nothing else would do and when it wasn't a mission critical thing, but rather a covenience thing. Glad you got it working!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Wierd that it worked for me and not for you (the one thing I did do was first set the focus to the OLE image field). I'm using Access 2003. I also got a reply to use:

    Application.CommandBars("edit").Controls("paste"). Execute

    but I haven't tried that yet.

    Cheers and thanks for trying to make it work Missinglinq.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  10. #10
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    For anybody interested here's a routine developed by Dev Ashish which replaces SendKeys with MySendKeys and has a reputation for being more reliable. All of the same arguements work.

    http://www.mvps.org/access/api/api0046.htm
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Geesh! My only excuse is I've a sick animal at home and have only had 10 hours sleep in the past 5 days, but I figured out why it, and 2 others

    DoCmd.RunCommand acCmdPaste

    Application.CommandBars("edit").Controls("paste"). Execute

    I'd been working with didn't work. I'd been clicking on a text box as the target of the Paste, then triggereing the event with the various attempted code behind a command box. This, of course, pulled the focus away from the text box, and it attempted to paste on the button! Corrected this and all three methods works!

    Think I'll get some sleep! Have a great weekend!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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