Forum Discussion
sara ranzato
Aug 04, 2017Copper Contributor
Problem with a new component
Hello to everybody, i have a problem. I've created a new excel component and i have registered it in my excel to use. The component works well. The problem is when i try to copy a seleceted area wi...
Bill Benson
Sep 27, 2017Tin Contributor
If your component can make use of public variables (I have never built components) you can try the following. Reference the Microsoft Forms 2.0 library, include a public boolean variable PreserveClipboard, and another public string variable called sClipBoardas well as dClipBoard declared as MSForms.DataObject:
Public PreserveClipboard As Boolean
Public dClipBoard As MSForms.DataObject
Public sClipBoard As String
Then in your routines, put this code.
If Application.CutCopyMode <> False Then
PreserveClipboard = True
Set dClipBoard = New MSForms.DataObject
dClipBoard.GetFromClipboard
sClipBoard = dClipBoard.GetText
End IfI don't know why it works, but it is how I cause my ribbon invalidate code not lose what the user is trying to copy when my ribbon invalidate code runs on Workbook_SheetSelectionChange and Workbook_SheetActivate events.