I am working on the C# vsto Excel application.
Whenever user pastes something in the excel template from another excel sheet,it also pastes Cell format along with the cell data in the excel template. I want to avoid this. So i googled & i came across term paste special.
Paste special will only paste the contents and will no alter the format of the current sheet.
I want to introduce paste special option in my vsto application.
I have code here,
Application.OnKey("^v", "PasteSpecV");
but its not working... can any one help me with this ?
After lots of search and try and error methods,i finally managed to do "Paste Special". The sheet on which i am working , i have delacred as Static Worksheet in the class called commonData
after that, i used that worksheet in ThisWorkbook.cs
On the ThisWorkbook Start up, i replaced PASTE(^v) by VBA Function Paste_cell
Open excel sheet on which you are working, Press ALT + F11 i.e. VBA Macros Editor.
Tools >> Macros >> Create new macro, It will create Module 1 in the Project Explorer, Paste the following code in the module1
Now,if you copy paste any value from any excel sheet,It will only paste the cell data and it will not paste its Format.It will prompt following message in order to alert user. So the original Format will not change.
Cheers, :-)
I used the following code to copy-paste only values and formatting using PasteSpecial in VSTO 2010
The line Clipboard.Clear() is the same as VBA CutCopyMode = False, to deselect what was selected to copy.
Add Reference MouseKeyboardActivityMonitor.dll