Forum Discussion
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 with key combination CTRL+C, excel run my component and doesn't make the copy. I canìt find a solution.
Somebody could help me?
I have excel 2016 and windows 10.
Thanks in advance
1 Reply
- Bill BensonTin 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 StringThen 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.