Error with copy/paste in excel 2010 VBA when trying to insert charts, ranges etc into word

前端 未结 4 1171
长发绾君心
长发绾君心 2021-01-18 16:39

In researching this error I\'ve come to the conclusion that it has to do with the clipboard not clearing like it should which wasn\'t an issue when we were using 2003 but is

4条回答
  •  走了就别回头了
    2021-01-18 17:09

    This is the code I use:

    Private Declare Function apiOpenClipboard Lib "user32" Alias "OpenClipboard" (ByVal hWnd As Long) As Long
    Private Declare Function apiEmptyClipboard Lib "user32" Alias "EmptyClipboard" () As Long
    Private Declare Function apiCloseClipboard Lib "user32" Alias "CloseClipboard" () As Long
    Private Declare Function CountClipboardFormats Lib "user32" () As Long
    
    Function ClipboardEmpty() As Boolean
        ClipboardEmpty = (CountClipboardFormats() = 0)
    End Function
    
    Sub EmptyClipboard()
      If apiOpenClipboard(0&) <> 0 Then
        Call apiEmptyClipboard
        Call apiCloseClipboard
      End If
    End Sub
    

    the function ClipboardEmpty is a test. e.g. if clipboardempty then
    The sub EmptyClipboard will simply clear the clipboard

提交回复
热议问题