|
Public Declare Sub Sleep Lib
"kernel32" (ByVal dwMilliseconds As Long)
Private Function
GetClipboardText() As String
On Error GoTo
ErrorHandler
Dim start As Date
start = Now
TryAgain:
DoEvents
Sleep 300
DoEvents
Dim text As String
text = Clipboard.GetText
GetClipboardText = text
Exit Function
ErrorHandler:
Dim errNum As Long
Dim errDescription As String
errNum = Err.Number
errDescription =
Err.Description
If
DateDiff("s", Now, start) > 5 Then
' Allow
time for the clipboard data to be sent to the clipboard
'
Otherwise you get the error 'Can't open clipboard
Err.Raise errNum,
" GetClipboardText", errDescription
Else
Resume TryAgain
End If
End Function
|