maintain original source formatting while pasting with Range.PasteSpecial

  • Thread starter Thread starter KrunalC
  • Start date Start date
K

KrunalC

Guest
This question is related to Office Interop.

I'm trying to paste RTF content in word document using method Range.PasteSpecial method. I have following line of code :

Clipboard.SetData(System.Windows.DataFormats.Rtf, text);
initialRange.PasteSpecial(DataType: Microsoft.Office.Interop.Word.WdPasteDataType.wdPasteRTF);

but problem with PasteSpecial is, it doesn't maintain the original formatting from the RTF source e.g. in my RTF source font of the text is Times New Roman but in resulting document after paste, font of the text is Calibri (which is the default font of word template file).

I'm aware about the method Range.PasteAndFormat method which accepts formatting option but I'm not able to use that method due to some reason.

Anyway to maintain original source formatting using PasteSpecial method?


Krunal C

Continue reading...
 
Back
Top