Capturing text in active cell to clipborad (Excel 95)

S

sth

My Excel programming skill are not very good, so plz excuse my
ignorance.

Through an Excel macro, I would like to automate capturing into the
clipboard the text in a selected cell. I have tried using
Selection.Copy
command but the app that will be receiving the copied cell returns an
errror message stating that only text can be pasted.

I also tried using this code, which I scavenged from
http://www.cpearson.com/excel/clipboar.htm:

Public Sub PutOnClipboard(Obj As Variant)
Dim MyDataObj As New DataObject
MyDataObj.SetText Format(Obj)
MyDataObj.PutInClipboard
End Sub

Public Function GetOffClipboard() As Variant
Dim MyDataObj As New DataObject
MyDataObj.GetFromClipboard
GetOffClipboard = MyDataObj.GetText()
End Function

Public Sub ClearClipboard()
Dim MyDataObj As New DataObject
MyDataObj.SetText ""
MyDataObj.PutInClipboard
End Sub

However, Excel 95 shows the following as error:
Dim MyDataObj As New DataObject

Is there a way to get Excel 95 (v 7.0) to perform this task?

Thx much.
 
S

Steve Garman

It's been a while, but if I recall correctly, there was a Clipboard
object back then.

Have you tried this:

Clipboard.Clear
Clipboard.SetText Range("A1").Text
My Excel programming skill are not very good, so plz excuse my
ignorance.

Through an Excel macro, I would like to automate capturing into the
clipboard the text in a selected cell. I have tried using
Selection.Copy
command but the app that will be receiving the copied cell returns an
errror message stating that only text can be pasted.

I also tried using this code, which I scavenged from
http://www.cpearson.com/excel/clipboar.htm:

<snip>
 
M

Michel Pierron

Hi sth;
Using DataObject need a reference to Microsoft Forms 2.0 Object Library
MP
 
S

sth

Steve, Thx for the attempt but those commands resulted in an error
message: "Object required."

=====
 

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