Consulting

Results 1 to 7 of 7

Thread: Clear Clipboard Contents

  1. #1
    VBAX Regular
    Joined
    May 2004
    Location
    Driffield, East Yorkshire, Egnland
    Posts
    69
    Location

    Question Clear Clipboard Contents

    Thanks to Mark for sorting my last query out... I've another question now.

    Part of my procedure is responsible for controlling a 3rd party app to run a query, the results of which are copied to the clipboard when completed (and then pasted into the excel workbook). It's got to be done this way as although the app DOES support DDE it's useless, like pre-1998 software!

    It is essential that the contents of the windows clipboard are emptied before this procedure is run - but I can't seem to control it properly. I'm running Win2K and Office2K.

    How do I clear the clipboard using VBA?

    Ad.

  2. #2
    VBAX Newbie
    Joined
    Jun 2004
    Posts
    4
    Location
    Try:

    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 Function ClearClipboard()
        OpenClipboard (0&)
        EmptyClipboard
        CloseClipboard
    End Function
    
    Sub Test()
    Call ClearClipboard
    End Sub

    THA

  3. #3
    BoardCoder
    Licensed Coder
    VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    622
    Location
    Try this:

    Private Declare Function EmptyClipboard Lib "user32" () As Long
    Private Declare Function CloseClipboard Lib "user32" () As Long
    Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Sub EmptyCB()
        dim hWnd as Long
        hWnd=FindWindow("XLMAIN", application.caption)
        OpenClipboard hWnd
        EmptyClipboard
        CloseClipboard
    End Sub

    [edit]Sometimes I wish you were locked out if someone else was posting![/edit]

    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net

  4. #4
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    THA!!??
    I thought you were no expert?? Hee hee...
    ~Anne Troy

  5. #5
    VBAX Newbie
    Joined
    Jun 2004
    Posts
    4
    Location
    I recently discovered I have access to a library of about 3 GB code etc for API/SQL/VB/VB.NET/C#/ASP.NET/VBA/VBScript/ADO/ADO.NET with a nice search-function on this computer.

    No need to be an expert - just enter searchword(s).

    Thomas

  6. #6
    VBAX Regular
    Joined
    May 2004
    Location
    Driffield, East Yorkshire, Egnland
    Posts
    69
    Location
    What can I possibly say...

    Thanks all

    Ad

  7. #7
    BoardCoder
    Licensed Coder VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    622
    Location
    I recently discovered I have access to a library of about 3 GB code etc for API/SQL/VB/VB.NET/C#/ASP.NET/VBA/VBScript/ADO/ADO.NET with a nice search-function on this computer.
    can you upload it LOL
    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net

Posting Permissions

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