Solved

Get Clipboard data

Posted on 2008-10-13
2
580 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

776 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