User Defined Type Not Defined

M

MT DOJ Help Desk

I have the following line in the Declarations of a module:

Dim cbValue As DataObject

When I try to run the macro, I get an error saying:

User defined type not defined.

I also have the following code in the macro:

' Trims any leading and trailing spaces from the clipboard value.
Set cbValue = New DataObject
cbValue.GetFromClipboard
cbLocate = Trim(cbValue.GetText)
cbValue.SetText cbLocate
cbValue.PutInClipboard

So I need to be able to move text to and from the clipboard. As I
understand it, I need a dataobject to do that. That same code in a form
works just fine. Does this mean that the way I have the macro written, it
will only work in a from? How do I make it work in a module?

--Tom
 
M

Malcolm Smith

Tom

You will need to add a reference to make this work. The reference is to
the Microsoft Forms 2.0 Object Library.

There are two ways to do this. I prefer the second one as it's miles
easier.

1. Open up Tools | References and locate the library and then check the
check box.

2. Add a new form to your code. Then delete it.


It now should compile. And, yes, I am not the only one who thinks that
this is an odd library for this object.

Cheers
- Malc
www.dragondrop.com
 
M

MT DOJ Help Desk

Malcolm,

It's been a busy couple of weeks, and I just got around to trying your
solutions. I could not get your second method to work for me, but the first
method worked just fine. Thanks for the help!

--Tom
 
M

Malcolm Smith

Tom

By form, I meant a new user form. Just having a form in the code
automagically pulls in the right reference. Deleting this form doesn't
remove this reference.

It's what I do when I have no user forms and can't remember the name of
the blasted thingummy.

- Malc
www.dragondrop.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top