I want to copy a variable to the clipboard using the PutInClipboard
-methode. Due to a known bug in Win10 I need to verify if the content of the clipboard is actually what it's suppose to be.
Unfortunalty it does not work as expected and I need to "enforce" the PutInClipboard
-methode by using the wait-Methode, otherwise the comparison returns true
, even though the values should not be the same:
'Put the content of a variable into the clipbaord
Dim strDesiredClipboardContent as String
Dim dataObject1 As DataObject
Set dataObject1 = New DataObject
dataObject1.SetText strDesiredClipboardContent
dataObject1.PutInClipboard
'Enforce Execution (otherwise the comparison in the end does not work)
Application.Wait Now + #12:00:01 AM#
'Get whatever is in the clipboard
Dim strActuallClipboardContent
Dim dataObject2 As MSForms.DataObject
Set dataObject2 = New MSForms.DataObject
dataObject2.GetFromClipboard
strActuallClipboardContent = dataObject2.GetText
'Compare
If strDesiredClipboardContent <> strActuallClipboardContent Then
MsgBox "Error"
End If
End Sub
I wonder if there is a different methode to enforce the complete execution of the PutInClipboard
-methode then using wait()
?! The goal would be to get the correct results but to ad as little "wait-time" as possible.