Simulate Ctrl-C (for Clipboard Copy):   Return to List

' API Constants and Declarations
Public Const VK_CONTROL = &H11 ' Control Key for Keyboard Event
Public Const VK_C = &H43 ' C for Keyboard Event
Public Const KEYEVENTF_KEYUP = &H2 ' Keyboard constant for Keyboard Event

Public Declare Sub keybd_event Lib "user32" _
    (ByVal bVk As Byte, _
    ByVal bScan As Byte, _
    ByVal dwFlags As Long, _
    ByVal dwExtraInfo As Long)

' Within a module
Clipboard.Clear

' Press Control.
keybd_event VK_CONTROL, 0, 0, 0
DoEvents

' Press C.
keybd_event VK_C, 1, 0, 0
DoEvents

' Release Control.
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
DoEvents

' Get the text from the clipboard.
Text1.Text = Clipboard.GetText



Note to Webmaster