After many search methods and attempts and errors, I finally managed to make a "Paste Special" . The sheet I'm working on, I have Delacred as a Static Worksheet in the commonData strong class >
class CommonData { public static Worksheet DATASHEET; }
after that i used this worksheet in ThisWorkbook.cs
At the start of ThisWorkbook, I replaced PASTE (^ v) with the VBA function Paste_cell
private void ThisWorkbook_Startup(object sender, System.EventArgs e) {
Open the excel sheet you are working on, press ALT + F11 , i.e. VBA macro editor.
Tools β Macros β Create a new macro, It will create module 1 in Project Explorer, Paste the following code into module1
Sub Paste_cell() If MsgBox("You are about to Paste only Values and not the format, proceed?", vbQuestion + vbOKCancel, GSAPPNAME) = vbOK Then On Error Resume Next ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:=False Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False End If End Sub
Now, if you copy any value from any excel sheet, it will only insert the cell data and will not paste its Format.It will trigger the following message to alert the user. Therefore, the original format will not change.
Greetings :-)