Solved

Get Clipboard data

Posted on 2008-10-13
2
577 Views
Last Modified: 2013-11-17
In OLE Automation how to retreive data from Clipboard for manupulation. Want to perform while Word document is opened and perform Ctrl+A operation.
0
Comment
Question by:ILGDRM
2 Comments
 
LVL 3

Accepted Solution

by:
DrunkenELF earned 500 total points
ID: 22701275
Dear ILGDRM,

Try the atatched Code..

Cheers!
D-ELF
Private Const CF_TEXT = 1

Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long

Private Declare Function CloseClipboard Lib "user32" () As Long

Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Long, ByVal ByteLen As Long)

Private Sub Form_Load()

    Dim hStrPtr As Long, lLength As Long, sBuffer As String

    OpenClipboard Me.hwnd

    hStrPtr = GetClipboardData(CF_TEXT)

    If hStrPtr <> 0 Then

        lLength = lstrlen(hStrPtr)

        If lLength > 0 Then

            sBuffer = Space$(lLength)

            CopyMemory ByVal sBuffer, ByVal hStrPtr, lLength

            MsgBox sBuffer, vbInformation

        End If

    End If

    CloseClipboard

End Sub

Open in new window

0
 

Author Comment

by:ILGDRM
ID: 22957361
This solution gives data from clipboard in predefined format. I want to caqpture the data irrespective of it's data type like data, image, object etc.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse package explorer vs project explorer view 2 84
creating threads in delphi 1 82
Adding Namespace to the second node of the xml 16 65
Advice in Xamarin 21 57
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

896 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now