Link to home
Start Free TrialLog in
Avatar of generali
generali

asked on

Clipboard...

Is there any way to detect what text is currently on the clipboard through some code in VBA?

Cheers
Matt
ASKER CERTIFIED SOLUTION
Avatar of R_Rajesh
R_Rajesh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of mvidas
mvidas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
R_Rajesh:

I wondered why the GetFromClipboard method worked in my Personal.xls and not in other Modules.  It was due to the missing references.  That is very helpful.

Thanks!

Jaes
Avatar of generali
generali

ASKER

I get the following error:

Dataobject:GetText Invalid FORMATETC structure

I am actually using code specific to an external application to copy the text, does this make any difference?

And I used:

If MyDataObj.GetText() = "" Then
GoTo MOD1RESUME
Else
Sheets("DataGather").Select
---------------------------
I can use "" cant I??
the clipboard content has to be in text format. try this
   
    Dim MyDataObj As New DataObject
    MyDataObj.GetFromClipboard
    If MyDataObj.GetFormat(1) = True Then
        MsgBox MyDataObj.GetText()
    Else
        MsgBox "Clipboard empty or Data in clipboard in not in text format"
    End If
Cheers again Rajesh, and thankyou OM !

Matt
thanks for the grade, Matt(generali)
could i ask you what OM stands for??
No probs rajesh, yeah OM stands for other Matt !  
:) Thanks!
lol, spent almost 5mins thinking of all combinations. wasn't even close :)
Heh, ohso much, old man, on me

Congrats on the wizard cert by the way! I'll officially congratulate you when an official congratulations thread shows up (I'd start one now but I have to run for a couple hours).

Cheers!
thanks Matt, I appreciate it.
still working hours at your end i believe :(  
its bed for me... :)