Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I run Excel code initiated by worksheet_change events and some of them kill the Clipboard content, making cut- and paste difficult. I have however noticed that the clipboard in the Task pane still contain the cut/copy content. Therefore, I want to add som code to always restore the clipboard content from taskpane to Excel clipboard. I will add the code in my worksheet_change event and run restore if the content differ, I guess. To start with - have anybody some code to suggest to transfere the content between them? Kind regards Tskogstrom |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Working with Windows clipboard is fairly straight forward, using the
DataObject exposed from MSForms. However, you can only work with the text format. Unless Office2003 and up have added functionality ? Private Sub CommandButton1_Click() Dim DatObj As DataObject Dim TempStr As String Const TEXTFORMAT As Long = 1 Range("rngCopy").Copy Set DatObj = New DataObject With DatObj .GetFromClipboard If .GetFormat(TEXTFORMAT) = True Then TempStr = .GetText End If .Clear .SetText TempStr, TEXTFORMAT .PutInClipboard End With Range("A20").Select ActiveSheet.Paste End Sub There is the Windows API that will give you complete access to the Windows clipboard in all formats, but that will require a lot more work to function correctly. In Excel 2000 only, you can work somewhat with the Office clipboard. Later version have the clipboard on the Task Pane and is not accessible, AFAIK. <Excel2K only Private Sub CommandButton1_Click() Dim ClipTBar As CommandBar Dim i As Long Const PASTEALL As Long = 2 Set ClipTBar = Application.CommandBars("Clipboard") With ClipTBar.Controls For i = 1 To .Count Debug.Print .Item(i).Caption Next .Item(PASTEALL).Execute End With End Sub </Excel2K only Other than that maybe Paste somewhere temporarily and copy/cut from there, if you cannot arrange your code to preserve the Clipboard and you need more than just text. NickHK "tskogstrom" wrote in message ups.com... Hi, I run Excel code initiated by worksheet_change events and some of them kill the Clipboard content, making cut- and paste difficult. I have however noticed that the clipboard in the Task pane still contain the cut/copy content. Therefore, I want to add som code to always restore the clipboard content from taskpane to Excel clipboard. I will add the code in my worksheet_change event and run restore if the content differ, I guess. To start with - have anybody some code to suggest to transfere the content between them? Kind regards Tskogstrom |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for answer,
I'll look into it. I want to cover Office 2003, but if possible also Office 2002 ( I think I already have some issues with 2000, forcing me to drop it, and of cource 97 isn't of this world to cover). I guess text cut/paste is most used. 2- However, often users copy/paste a range of cells. That particular case, I belive I had to cover as well. Maybe I can store the selected range and if the clipboard turned empty, by code i select the range again and copy it? I need to check of it is empty, because it might stall the users fluency othervice, If it take a while to run. Any idea about that, or should we leave that open, to others to suggest? Is the clipboard empty if ".GetFormat(TEXTFORMAT) = False"? or could it be other objects like chartobjects etc? 3 - The third case I belive will make a fuss is when users try to copy chartobjects and paste it into powerpoint files. Kind regards Tskogstrom On 6 Mar, 10:08, "NickHK" wrote: Working with Windows clipboard is fairly straight forward, using the DataObject exposed from MSForms. However, you can only work with the text format. Unless Office2003 and up have added functionality ? Private Sub CommandButton1_Click() Dim DatObj As DataObject Dim TempStr As String Const TEXTFORMAT As Long = 1 Range("rngCopy").Copy Set DatObj = New DataObject With DatObj .GetFromClipboard If .GetFormat(TEXTFORMAT) = True Then TempStr = .GetText End If .Clear .SetText TempStr, TEXTFORMAT .PutInClipboard End With Range("A20").Select ActiveSheet.Paste End Sub There is the Windows API that will give you complete access to the Windows clipboard in all formats, but that will require a lot more work to function correctly. In Excel 2000 only, you can work somewhat with the Office clipboard. Later version have the clipboard on the Task Pane and is not accessible, AFAIK. <Excel2K only Private Sub CommandButton1_Click() Dim ClipTBar As CommandBar Dim i As Long Const PASTEALL As Long = 2 Set ClipTBar = Application.CommandBars("Clipboard") With ClipTBar.Controls For i = 1 To .Count Debug.Print .Item(i).Caption Next .Item(PASTEALL).Execute End With End Sub </Excel2K only Other than that maybe Paste somewhere temporarily and copy/cut from there, if you cannot arrange your code to preserve the Clipboard and you need more than just text. NickHK "tskogstrom" wrote in message ups.com... Hi, I run Excel code initiated by worksheet_change events and some of them kill the Clipboard content, making cut- and paste difficult. I have however noticed that the clipboard in the Task pane still contain the cut/copy content. Therefore, I want to add som code to always restore the clipboard content from taskpane to Excel clipboard. I will add the code in my worksheet_change event and run restore if the content differ, I guess. To start with - have anybody some code to suggest to transfere the content between them? Kind regards Tskogstrom- Dölj citerad text - - Visa citerad text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to copy task pane to clipboard? | Excel Discussion (Misc queries) | |||
Clipboard empty but still get waring that clipboard is full | Excel Discussion (Misc queries) | |||
Restore clipboard from Task pane clipboard content? | Excel Programming | |||
ClearContents or ClearFormats also clears Clipboard. How can I keep the clipboard? | Excel Programming | |||
Clearing the Clipboard task pane in XL ( XP ) !!! | Excel Programming |