Hello.

There is a script. The user copies text data in a specific format and wants to insert them into an Excel 2010 spreadsheet.

It is required in the Add-In to intercept this data, parse and paste it into the cells with the desired design.

Is it possible to do this in C # using VSTO?

I try through the command element in RibbonUI , but I can’t find the idMso I need:

 <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage="GetImage" onLoad="OnLoadRibonUI" > <commands> <command idMso="PasteTextOnly" onAction="OnAction" /> </commands> </customUI> 

    1 answer 1

    There is a SheetChange event that is triggered after any changes on the sheet. This is the way to understand that the insertion occurred.

     private void Application_SheetChange(object Sh, Excel.Range Target) { var t = this.Application.CommandBars["Standard"].Controls["&Undo"]; if (t.TooltipText == "&Undo Paste (Ctrl+Z)") { } } 

    In theory, then you can do the formatting, call Undo and replace it with your own formatting.

    I don’t know, maybe a more beautiful way to prevent an unnecessary insertion altogether and insert immediately formatted text.


    Found a solution through WinApi .

    It consists in the interception of shortcuts.

    If you caught CTRL + V, then you turn it off, and you yourself take information from the clipboard.

    • What about Excel localization? In Russian, German, etc. also works? - mals
    • At the expense of localization is not possible to check, as are the English office. However, access to the controls can be obtained by index. There is a second option, which is the perception of user buttons. - iluxa1810