问题
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