Solved

Get Clipboard data

Posted on 2008-10-13
2
572 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoresClump  challenge 31 107
wordlen challenge 3 46
Scripting vs. Programming languages 25 110
C# code editing and collaboration 3 39
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 post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

772 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

13 Experts available now in Live!

Get 1:1 Help Now