c# - (Interop.Word) Range.Copy-Range.Paste work slow -


i use microsoft.office.interop.word create new doc based on doc. there multiple iterations search/replace operations using range.text , work pretty fast. however, in 1 case need copy entire chapter formatting , instead of range.text (which resets formatting) used range.copy , range.paste. work, test chapter 450 words, take 40 sec (vs. less 1 sec when change same code use range.text).

question: there way make range.copy/range.paste faster? need find particular piece of text , copy tables, formatting, etc. file.

if want copy text formatting in word can use formattedtext property of range like

targetrange.formattedtext = sourcerange.formattedtext; 

avoid using range.copy() , range.paste() approach internally use clipboard may cause security problems or may provide unpredictable results in cases


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -