VBA 获取粘贴板文本 使用Microsoft HTML Obiect Library

 

相关的MSDN文档

https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752706(v=vs.85)

 

Public Function GetClipboardText() As String
    ' 早期绑定必须要 点击 工具>引用 引用 Microsoft HTML Obiect Library
    Dim doc As New HTMLDocument
    
    Dim win As HTMLWindow2
    
    Dim data As IHTMLDataTransfer
    
    Set win = doc.parentWindow
        
        
    Set data = win.clipboardData
    ' "text" 是一个标志 另一个标志是 "URL"
    GetClipboardText = data.GetData("text")
    
    
End Function

 

posted @ 2021-11-18 19:47  FfD4edyo  阅读(306)  评论(0)    收藏  举报