c# - Word interop - find and replace text in Symbol font onlyl -
i want find , replace text in word document if in symbol font using c#
this code far:
static void find_replace_text(string find_s, string replace_s, document document) { object missing = system.reflection.missing.value; range rng = document.range(0, document.content.end); find findobject = rng.find; findobject.clearformatting(); findobject.text = find_s; findobject.replacement.clearformatting(); findobject.replacement.text = replace_s; findobject.font.name = "symbol"; findobject.format = true; object replaceall = wdreplace.wdreplaceall; findobject.execute(ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, true, ref replaceall, ref missing, ref missing, ref missing, ref missing); }
my code not give me expected result. when remove lines set font name , format true, code replaces occurrences of search string regardless of font. instance, trying replace alpha symbol (from symbol font) has character code 97. without font name being set in code occurrences of letter 'a' (ascii 97) replaced. need code font aware.
update
i can confirm code works in case symbols have been added word changing font 'symbol', not when symbol has been added document via symbol ui (which, unfortunately how done in documents need process).
Comments
Post a Comment