PDA

View Full Version : [SOLVED:] Clear Clipboard Contents



Adaytay
06-15-2004, 05:49 AM
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.

THA
06-15-2004, 06:19 AM
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

mark007
06-15-2004, 06:21 AM
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


Sometimes I wish you were locked out if someone else was posting!

:)

Anne Troy
06-15-2004, 06:30 AM
THA!!??
I thought you were no expert?? Hee hee...

THA
06-15-2004, 06:38 AM
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

Adaytay
06-15-2004, 06:41 AM
What can I possibly say...

Thanks all :D

Ad

mark007
06-15-2004, 06:42 AM
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 :giggle