Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Error using DataObject to get clipboard data

I'm using VBA to try to get the data on the clipboard in Excel. I've found
suggestion that are variations on the following:

Dim MyData As DataObject
Set MyData = New DataObject
Dim sClipText As String
On Error GoTo NotText
MyData.GetFromClipboard
sClipText = MyData.GetText(1)

When this sub gets called in my Excel macro, I get "User Defined Type not
defined" on the first line.

Also, once this is resolved, is there a way to determine if the data on the
clipboard can be pasted into Excel (sometimes you do something in Excel that
seems to clear out the clipboard).

Any suggestions?
Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Error using DataObject to get clipboard data

I've found the solution but iut puzzles me. Maybe somebody can explain it
better.

I found by adding a userform (Insert Userform) to the VBA project creates a
refernce (tools _ References) to the Microsoft forms 2.0 object library.
Once the object library is listed as a reference the Dataobject doesn't
create an error.

The thing that puzzle me is i can't just go and add the Userform refernce.
it is not in the libraries.

"stocktsi" wrote:

I'm using VBA to try to get the data on the clipboard in Excel. I've found
suggestion that are variations on the following:

Dim MyData As DataObject
Set MyData = New DataObject
Dim sClipText As String
On Error GoTo NotText
MyData.GetFromClipboard
sClipText = MyData.GetText(1)

When this sub gets called in my Excel macro, I get "User Defined Type not
defined" on the first line.

Also, once this is resolved, is there a way to determine if the data on the
clipboard can be pasted into Excel (sometimes you do something in Excel that
seems to clear out the clipboard).

Any suggestions?
Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Error using DataObject to get clipboard data

If you were stepping through the code, then you can't set a reference.

I'd try it again.

joel wrote:

I've found the solution but iut puzzles me. Maybe somebody can explain it
better.

I found by adding a userform (Insert Userform) to the VBA project creates a
refernce (tools _ References) to the Microsoft forms 2.0 object library.
Once the object library is listed as a reference the Dataobject doesn't
create an error.

The thing that puzzle me is i can't just go and add the Userform refernce.
it is not in the libraries.

"stocktsi" wrote:

I'm using VBA to try to get the data on the clipboard in Excel. I've found
suggestion that are variations on the following:

Dim MyData As DataObject
Set MyData = New DataObject
Dim sClipText As String
On Error GoTo NotText
MyData.GetFromClipboard
sClipText = MyData.GetText(1)

When this sub gets called in my Excel macro, I get "User Defined Type not
defined" on the first line.

Also, once this is resolved, is there a way to determine if the data on the
clipboard can be pasted into Excel (sometimes you do something in Excel that
seems to clear out the clipboard).

Any suggestions?
Thanks.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Error using DataObject to get clipboard data

Dave: i wasn't stepping through the code. You can't even select REFERENCE if
you are stepping. I created a new workbook with a one line macro.

Sub Test
Dim MyData As DataObject

end Sub


I compiled the code using debug Compile and got an error. Then went to
Refernce and looks for the Microsoft Forms 2.0 object librzary and couldn't
find it. Next I added a userform and went back to the REFERENCE menu and the
form was listed and checked. I then compiled and didn't get the error.
"Dave Peterson" wrote:

If you were stepping through the code, then you can't set a reference.

I'd try it again.

joel wrote:

I've found the solution but iut puzzles me. Maybe somebody can explain it
better.

I found by adding a userform (Insert Userform) to the VBA project creates a
refernce (tools _ References) to the Microsoft forms 2.0 object library.
Once the object library is listed as a reference the Dataobject doesn't
create an error.

The thing that puzzle me is i can't just go and add the Userform refernce.
it is not in the libraries.

"stocktsi" wrote:

I'm using VBA to try to get the data on the clipboard in Excel. I've found
suggestion that are variations on the following:

Dim MyData As DataObject
Set MyData = New DataObject
Dim sClipText As String
On Error GoTo NotText
MyData.GetFromClipboard
sClipText = MyData.GetText(1)

When this sub gets called in my Excel macro, I get "User Defined Type not
defined" on the first line.

Also, once this is resolved, is there a way to determine if the data on the
clipboard can be pasted into Excel (sometimes you do something in Excel that
seems to clear out the clipboard).

Any suggestions?
Thanks.


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Error using DataObject to get clipboard data

I don't have another guess.

If you close excel and reopen (with an empty workbook) and then straight to the
VBE, can you set the reference then?

(Maybe you just missed it in the reference list. It shows up near the top for
me (xl2003). Maybe you looked in the alphabetical list below???)

joel wrote:

Dave: i wasn't stepping through the code. You can't even select REFERENCE if
you are stepping. I created a new workbook with a one line macro.

Sub Test
Dim MyData As DataObject

end Sub

I compiled the code using debug Compile and got an error. Then went to
Refernce and looks for the Microsoft Forms 2.0 object librzary and couldn't
find it. Next I added a userform and went back to the REFERENCE menu and the
form was listed and checked. I then compiled and didn't get the error.
"Dave Peterson" wrote:

If you were stepping through the code, then you can't set a reference.

I'd try it again.

joel wrote:

I've found the solution but iut puzzles me. Maybe somebody can explain it
better.

I found by adding a userform (Insert Userform) to the VBA project creates a
refernce (tools _ References) to the Microsoft forms 2.0 object library.
Once the object library is listed as a reference the Dataobject doesn't
create an error.

The thing that puzzle me is i can't just go and add the Userform refernce.
it is not in the libraries.

"stocktsi" wrote:

I'm using VBA to try to get the data on the clipboard in Excel. I've found
suggestion that are variations on the following:

Dim MyData As DataObject
Set MyData = New DataObject
Dim sClipText As String
On Error GoTo NotText
MyData.GetFromClipboard
sClipText = MyData.GetText(1)

When this sub gets called in my Excel macro, I get "User Defined Type not
defined" on the first line.

Also, once this is resolved, is there a way to determine if the data on the
clipboard can be pasted into Excel (sometimes you do something in Excel that
seems to clear out the clipboard).

Any suggestions?
Thanks.


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message: Cannot empty the clipboard. Carolyn Excel Discussion (Misc queries) 1 December 27th 06 07:28 PM
Unable to empty clipboard error Elliot Gingold Excel Discussion (Misc queries) 2 February 23rd 06 01:17 AM
error: cannot empty the Clipboard Jane New Users to Excel 0 December 29th 05 07:59 PM
"cannot empyt clipboard" error AP Excel Discussion (Misc queries) 0 February 9th 05 05:37 PM
Clipboard Error Joe Black Excel Discussion (Misc queries) 0 December 13th 04 12:34 PM


All times are GMT +1. The time now is 06:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"