Forum Discussion

sara ranzato's avatar
sara ranzato
Copper Contributor
Aug 04, 2017

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

  • 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 If

    I 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.