Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Clear clipboard
Hi
How can I clear the clibboard from VBA code? I have an application which copies a lot of data, which I want to remove once it's been used. Many thanks -- Nick |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Clear clipboard
Hello Nick, Add a VBA module to your project and add this code to it. CALLING THE MACRO: ClearClipboard Code: -------------------- Declare Function OpenClipboard _ Lib "User32.dll" _ (ByVal hWndNewOwner As Long) As Long Declare Function EmptyClipboard _ Lib "User32.dll" () As Long Declare Function CloseClipboard _ Lib "User32.dll" () As Long Public Sub ClearClipboard() Dim Ret Ret = OpenClipboard(0&) If Ret < 0 Then Ret = EmptyClipboard CloseClipboard End Sub -------------------- Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=484632 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Clear clipboard
NickH:
Application.CutCopyMode = False -- http://www.vba.com.tw/plog/ "NickH" wrote: Hi How can I clear the clibboard from VBA code? I have an application which copies a lot of data, which I want to remove once it's been used. Many thanks -- Nick |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Clear clipboard
Thanks for such prompt response, Leith
I have tried this, but it doesn't appear to work. If I step through the module, Ret always gets a value of 1, even on consecutive runs. With the clibboard visible, the contents remain unchanged. I don't know if it's relevant, but I'm using Office 2003 and I'm looking at the "Office Cliboard" which indicates "1 of 24" entries as I type. The source data comes from an Outlook message, which I copy manually (<ctrl-C). -- Nick "Leith Ross" wrote: Hello Nick, Add a VBA module to your project and add this code to it. CALLING THE MACRO: ClearClipboard Code: -------------------- Declare Function OpenClipboard _ Lib "User32.dll" _ (ByVal hWndNewOwner As Long) As Long Declare Function EmptyClipboard _ Lib "User32.dll" () As Long Declare Function CloseClipboard _ Lib "User32.dll" () As Long Public Sub ClearClipboard() Dim Ret Ret = OpenClipboard(0&) If Ret < 0 Then Ret = EmptyClipboard CloseClipboard End Sub -------------------- Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=484632 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Clear clipboard
Hello Nick, I'm glad you mentioned youu are trying to clear the Office Clipboard. The API code I posted is for the Windows Clipboard. Here is some information about the Office Clipboard... In versions of Excel earlier than Excel 2000, you can copy and paste an item anywhere within a worksheet until you perform an action that clears the clipboard. The Office Clipboard retains information about pasted items so that you can perform other tasks without clearing the clipboard and then paste items as you need them. The Office Clipboard does not replace the Windows Clipboard, which can only store a single item. The data stored in the Office Clipboard is stored in HTML format. The contents of the Office Clipboard are deleted when the current session ends. If you have one Office program running, the contents of the Office Clipboard are deleted when you close that program. If you have multiple Office programs running, the contents of the Office Clipboard are deleted after you close the last Office program. There is no Visual Basic for Applications object model for the Office Clipboard, so there is no way to programmatically manipulate it. You can easily clear all the clipboards that are stored in the Office Clipboard. To clear the Office Clipboard, click Clear Clipboard on the Clipboard toolbar. Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=484632 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Clear clipboard
Hi Leith,
Thank you for your comprehensive reply. You have taught me something new about the clipboard, which is useful to know. I'm not sure what this means in terms of my using the applications, but I will pay attention to what happens based on the information you've supplied. Kind regards, Nick -- Nick "Leith Ross" wrote: Hello Nick, I'm glad you mentioned youu are trying to clear the Office Clipboard. The API code I posted is for the Windows Clipboard. Here is some information about the Office Clipboard... In versions of Excel earlier than Excel 2000, you can copy and paste an item anywhere within a worksheet until you perform an action that clears the clipboard. The Office Clipboard retains information about pasted items so that you can perform other tasks without clearing the clipboard and then paste items as you need them. The Office Clipboard does not replace the Windows Clipboard, which can only store a single item. The data stored in the Office Clipboard is stored in HTML format. The contents of the Office Clipboard are deleted when the current session ends. If you have one Office program running, the contents of the Office Clipboard are deleted when you close that program. If you have multiple Office programs running, the contents of the Office Clipboard are deleted after you close the last Office program. There is no Visual Basic for Applications object model for the Office Clipboard, so there is no way to programmatically manipulate it. You can easily clear all the clipboards that are stored in the Office Clipboard. To clear the Office Clipboard, click Clear Clipboard on the Clipboard toolbar. Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=484632 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Why does it clear my clipboard? | Excel Discussion (Misc queries) | |||
Clipboard clear | Excel Programming | |||
clear the clipboard? | Excel Programming | |||
Clear Clipboard in VB | Excel Programming | |||
Clear clipboard | Excel Programming |