VBA參考代碼:
OptionExplicit#IfVBA7ThenPublicDeclarePtrSafeFunctionOpenClipboardLib"user32"(ByValhwndAsLongPtr)AsLongPublicDeclarePtrSafeFunctionCloseClipboardLib"user32"()AsLongPublicDeclarePtrSafeFunctionEmptyClipboardLib"user32"()AsLong#ElsePublicDeclareFunctionOpenClipboardLib"user32"(ByValhwndAsLongPtr)AsLongPublicDeclareFunctionCloseClipboardLib"user32"()AsLongPublicDeclareFunctionEmptyClipboardLib"user32"()AsLong#EndIfSubCallEC()DimlngRetAsLonglngRet=OpenClipboard(Application.hwnd)IflngRetThenEmptyClipboardCloseClipboardEndIfEndSub
先復制一段文字到剪貼板,然后運行CallEC過程,之后便會看到剪貼板被清空了。