Copying Text using ClipBoard_SetData() doesn't work

随声附和 提交于 2020-01-07 02:24:09

问题


I'm calling a function to copy text to the Windows clipboard using the API function from http://support.microsoft.com/kb/210216 using Access 2003 on Windows XP.

The function does clear the Clipboard, but it silently fails on the actual assignment to the clipboard. Stepping through the code and querying for errors in the immediate window yields nothing.

I copied and pasted the MS function exactly as shown on their webpage.


回答1:


I use this function, which does almost exactly the same thing. It uses the Registry Key to the Clipboard. Try it out.

Public Sub CopyTextToClipboard(ByVal inText As String)
'***************************************
'       Background copy of any Text
'***************************************
    Dim objClipboard As Object
    Set objClipboard = CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")

    objClipboard.SetText inText
    objClipboard.PutInClipboard

    Set objClipboard = Nothing
End Sub

So to copy any test you simply use,

CopyTextToClipboard "Hello World !!"

Then use Ctrl+V to paste it.



来源:https://stackoverflow.com/questions/25430723/copying-text-using-clipboard-setdata-doesnt-work

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