How to check if clipboard is empty of text?

独自空忆成欢 提交于 2019-11-29 07:54:21

Very important: You must first set a reference to the "Microsoft Forms 2.0 Object Library" (as in the attached screenshot below) before implementing this code. You may find that it is not an option when you scroll through the reference libraries. To make it show up, just add a form to the project (you can always delete the form later).

Sub CheckClipboard()

        Dim myDataObject As DataObject

        Set myDataObject = New DataObject


        myDataObject.GetFromClipboard


        If myDataObject.GetFormat(1) = True Then 

            '''There is text on clipboard, so it's safe to paste

        Else 
            '''there is no text on the clipboard, so you may get error.

        End If

End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!