+ Reply to Thread
Results 1 to 3 of 3

Clearing clipboard with VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    11-24-2006
    Location
    Bristol, UK
    Posts
    34

    Clearing clipboard with VBA

    Hi guys

    Hopefully an easy one: Is there a way of clearing the Windows clipboard using VBA?

    I've got some code that places large amounts of data on the clipboard, and I seem to be having memory problems. If I could clear the data mid-code, I think the problem should resolve.

    Please tell me it's a simple line in VBA!

    Any help appreciated, thanks

    Nick

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    Put this code in a module:

    Option Explicit
    Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
    Public Declare Function EmptyClipboard Lib "user32" () As Long
    Public Declare Function CloseClipboard Lib "user32" () As Long
    
    Public Sub ClearClipboard()
        OpenClipboard (0&)
        EmptyClipboard
        CloseClipboard
    End Sub
    To clear clipboard put the code:
    Call ClearClipboard
    in your sub

    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    11-24-2006
    Location
    Bristol, UK
    Posts
    34
    Excellent! Thanks very much.

    Nick

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1