View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
fred fred is offline
external usenet poster
 
Posts: 73
Default Using a custom format on the clipboard

I want to put some data on the clipboard and retreive it but using a custom
format.
I tried the code below. I run myCopy and it works fine but myPaste fails
when trying to retreive the data (myStr = myDataObj.GetText("myFormat"))
with the error message:
Dataobject: Gettext invalid FORMATETC structure.

Can someone help me make this work. I want to use a custom format because I
also want to keep some standard text data in the clipboard.

Thanks
Fred


Sub myCopy()
Dim myDataObj As DataObject

Set myDataObj = New DataObject
myDataObj.SetText Selection.Cells(1).Value, "myFormat"
myDataObj.PutInClipboard
Set myDataObj = Nothing
End Sub

Sub myPaste()
Dim myStr As String
Dim myDataObj As DataObject

Set myDataObj = New DataObject
myDataObj.GetFromClipboard
myStr = myDataObj.GetText("myFormat")
MsgBox myStr
Set myDataObj = Nothing
End Sub