Solved

Using SendKeys to send Ctrl_c

Posted on 2007-03-17
5
436 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 86

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 47

Author Comment

by:Martin Liss
ID: 18742565
Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

751 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