[Resolved] Capture required data from ClipBoard
Hi,
I need to select particular data from clip board and paste it into my word document. How can i do that?
Let's say I have the following data/Text in ClipBoard:
Student ID: 123
Student Name: ABC
Class: 12th
Year: 2005-06
I need to capture the student Name "ABC" alone.
How can I achieve that?
Thanks in advance.
CS.
Re: Capture required data from ClipBoard
I successfully tested this (based on the example):
VB Code:
Dim MyData As DataObject
Dim strArr() As String
Dim intCount As Integer
Dim intIdx As Integer
Set MyData = New DataObject
'Obtain the data from the ClipBoard
MyData.GetFromClipboard
'Split the data into an Array
strArr() = Split(MyData.GetText(1), vbCrLf)
intCount = UBound(strArr)
For intIdx = 0 To intCount
If InStr(strArr(intIdx), "Student Name:") Then
MsgBox Trim$(Split(strArr(intIdx), "Student Name:")(1))
End If
Next
You may need adional validation of data, but this is a place to start :)
Re: Capture required data from ClipBoard
Thanx Bruce!
I think this will work fine in Visual basic. But I want to use this function in VBA for Word / Excel.
I tried but it is not working. Pls Help!!!!!!!!!!!!!!!!
CS.
Re: Capture required data from ClipBoard
Re: Capture required data from ClipBoard
Hi,
Thanx! for you reply.
Previously it was not working for me. At last i found the key.
I haven't set the reference to Microsoft Forms 2.0 object library in my VBA project.
That's the problem.
Now the same code which you gave works fine for me.
Thanks a lot!
CS.
Re: [Resolved] Capture required data from ClipBoard