Results 1 to 6 of 6

Thread: [Resolved] Capture required data from ClipBoard

  1. #1

    Thread Starter
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Resolved [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.
    Last edited by cssriraman; Nov 12th, 2005 at 12:08 AM. Reason: Change the status to Resolved

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Capture required data from ClipBoard

    I successfully tested this (based on the example):
    VB Code:
    1. Dim MyData As DataObject
    2. Dim strArr() As String
    3. Dim intCount As Integer
    4. Dim intIdx As Integer
    5.  
    6.     Set MyData = New DataObject
    7.  
    8.     'Obtain the data from the ClipBoard
    9.     MyData.GetFromClipboard
    10.     'Split the data into an Array
    11.     strArr() = Split(MyData.GetText(1), vbCrLf)
    12.  
    13.     intCount = UBound(strArr)
    14.  
    15.     For intIdx = 0 To intCount
    16.         If InStr(strArr(intIdx), "Student Name:") Then
    17.             MsgBox Trim$(Split(strArr(intIdx), "Student Name:")(1))
    18.         End If
    19.     Next

    You may need adional validation of data, but this is a place to start

  3. #3

    Thread Starter
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    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.

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Capture required data from ClipBoard

    As per the PM

  5. #5

    Thread Starter
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    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.

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: [Resolved] Capture required data from ClipBoard

    No probs.

    Good luck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width