Solved

Using SendKeys to send Ctrl_c

Posted on 2007-03-17
5
432 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

828 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