Solved

Using SendKeys to send Ctrl_c

Posted on 2007-03-17
5
427 Views
Last Modified: 2010-04-30
Why in the world doesn't this work

    Clipboard.Clear
    SendKeys "^c", True ' Ctrl_c ???
    MsgBox Clipboard.GetText
0
Comment
Question by:Martin Liss
5 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 50 total points
ID: 18742455
How are you firing that code?

If, for instance, you fired it in a button click:

    Private Sub Command1_Click()
        Clipboard.Clear
        SendKeys "^c", True ' Ctrl_c ???
        MsgBox Clipboard.GetText
    End Sub

Then the BUTTON would have focus last and there would be nothing to copy...therefore returning a blank string.

If you set focus onto something else first though, like a TextBox...then you get very different results:

    Private Sub Command1_Click()
        Text1.SetFocus
        Text1.SelStart = 0
        Text1.SelLength = Len(Text1.Text)
        Clipboard.Clear
        SendKeys "^c", True ' Ctrl_c ???
        MsgBox Clipboard.GetText
    End Sub
0
 
LVL 46

Author Comment

by:Martin Liss
ID: 18742565
Thanks.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question