+ Reply to Thread
Results 1 to 3 of 3

Not able to use DataObject

Hybrid View

bristly Not able to use DataObject 05-16-2008, 10:24 AM
Leith Ross Hello bristly, You don't... 05-16-2008, 02:49 PM
bristly Hello Mr. Ross, thank you... 05-19-2008, 12:29 PM
  1. #1
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Prague
    Posts
    145

    Not able to use DataObject

    Hi,
    I'm trying to define an object for copying from Clipboard.

    Dim MyData as DataObject
    etc.

    But this very first statement (within a procedure) fails:
    Compile error: User-defined type not defined

    What am I doing wrong? I thought this was a default data type.

    Thanks a lot!

    The example from MS VB Help follows:
    Dim MyData as DataObject
    
    Private Sub CommandButton1_Click()
        'Need to select text before copying it to Clipboard
        TextBox1.SelStart = 0
        TextBox1.SelLength = TextBox1.TextLength
        TextBox1.Copy
    
        MyData.GetFromClipboard
        TextBox2.Text = MyData.GetText(1)
    End Sub
    
    Private Sub UserForm_Initialize()
        Set MyData = New DataObject
        TextBox1.Text = "Move this data to the " _
            & "Clipboard, to a DataObject, then to "
            & "TextBox2!"
    End Sub
    Last edited by Leith Ross; 05-16-2008 at 12:40 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello bristly,

    You don't provide much information about your code or your system. DataObject is part of the MS Forms 2.0 object library. This library is automatically loaded whenever you insert a UserForm in your VBA project. If the library is not loaded then you are referencing a non existent object and will get this error.

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    11-13-2007
    Location
    Prague
    Posts
    145
    Hello Mr. Ross,
    thank you for your help. I'm quite new with macros, so I had no clue about the existence of libraries so far :-).
    So thank you again.
    Bristly

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1