Get text from clipboard using GetText – avoid error on empty clipboard
Handle the errors with On Error GoTo as shown here: Sub GetClipBoardText() Dim DataObj As MSForms.DataObject Set DataObj = New MsForms.DataObject ‘<~~ Amended as per jp’s suggestion On Error GoTo Whoa ‘~~> Get data from the clipboard. DataObj.GetFromClipboard ‘~~> Get clipboard contents myString = DataObj.GetText(1) MsgBox myString Exit Sub Whoa: If Err <> 0 Then … Read more