Reading clipboard contents in VBA

W

Warrick

Hi,

Has anyone had any success with the following code
(Microsoft kbid=212730)??
It fails everytime for me with a Run-Time error when the
gettext runs.
I hope someone can help! I've about given up!
Thanks
Warrick


Sub GetClipBoardText()
Dim MyData As DataObject
Set MyData = New DataObject
Dim sClipText As String
On Error GoTo NotText

' Get data from the clipboard.
MyData.GetFromClipboard

' Assign clipboard contents to string variable
sClipText.
sClipText = MyData.GetText(1)
MsgBox sClipText

NotText:

If Err <> 0 Then
MsgBox "Data on clipboard is not text."
End If

End Sub
 
G

Guest

Sorry, I forgot to mention I am running Offic X on a Mac
running 10.3......The code works on PC's.
 
A

Andrew Savikas

Are you sure you've set the needed reference

"IMPORTANT: For this code to run, you need to add a reference to the Microsoft Forms 2.0 Object Library.

Though I'm not even sure that reference would be available on a Mac.

-- Andrew
 
W

Warrick

Yes the refrence is definately loaded. I can save to the
clipboard but just cannot get from it.
Warrick
-----Original Message-----
Are you sure you've set the needed reference?

"IMPORTANT: For this code to run, you need to add a
reference to the Microsoft Forms 2.0 Object Library."
 

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