Place Clipboard Info into Variable

D

Debra Ann

I want to place the information contained in the clipboard (which is an
integer) into a variable so that I can increment the number and place it
somewhere else in my document. How do I do that?
 
B

Brett

I used code in Greg Maxey post as a template in the
following. If there is nothing in the clipboard, it gives
a run time error at the line:
clipText = dObj.GetText

(Is there a way to capture the msgBox text -- its fairly long).

The whole reason for doing this function is to detect if
someone should have copied, but didn't -- so a paste
command wouldn't bomb with a cryptic error message
for non programmers.

Now it bombs with a different cryptic error message -- is
there a way to check that clipboard is empty so you can
quit gracefully?

Any help is much appreciated

' Pass the min Length that should be in clipboard in 'minTextSize'
' If actual clipboard size is less than that, return False, otherwise return
True
' Also return the actual clipboard text in 'clipText' for additional tests
' in calling code if needed
Function pastedEnough(minTextSize As Long, clipText As String) As Boolean
Dim dObj As DataObject

Set dObj = New DataObject
dObj.GetFromClipboard
clipText = dObj.GetText

If (Len(clipText) < minTextSize) Then
pastedEnough = False
Exit Function
End If

pastedEnough = True
End Function
 

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