I am creating a doc file and writing a text containing ^m in it and facing issue. Does this ^m is a special character for doc file ? If I replace ^m with some other characters (like ^m with >m or any other) then It works fine. I faced this issue with other characters too like ^a and few other. What could be the solution ?
+1
A:
^M -- as in: Control-M -- is often used to type a 'carriage return' character (ASCII-code 13 in decimal, 0D in hex).
jschulenklopper
2010-05-27 13:25:07
I am trying to replace a tag [some_tag] with a text having ^m (like ERR^m) using Word Inerop library function Range.Find.Execute, when it tries to replace, it throws exception and quits. Please suggest how to insert ^m and other characters with ^.
Safiullah
2010-05-27 13:36:54
Depends on the text editor that you're using. Are you looking for one character (shown as ^m) or is it really two characters, a caret and an m (or another letter)? A caret is just inserted by entering a caret.You should look how to escape that ^-character, for example by entering a single quote / double quote, or a backslash.W.r.t. to the Find.Execute method, did you see the documentation on http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.find.execute(office.11).aspx? There are parameters like MatchWildcards and MatchControl that might help.
jschulenklopper
2010-05-27 14:47:29
If I replace ^ with any other character, it works fine. I am using C# for this. Even I tried in this way as well, first I replaced ^ with ` and then I replaced ` with ^ only even then I got error. please help.
Safiullah
2010-05-28 10:51:51
A:
It could be that it is evaluated as an logical expression. Try to escape it either prepending ' before it, or \ .
arunas_t
2010-05-27 13:25:08
Can you please explain, what should I do ? Should I replace ^m with \^m or with ^\m or '\m or \'m or `\m ??? Thanks for help.
Safiullah
2010-05-27 13:46:34
try \^m or \x5E (hexadecimal for ASCII). So first format Your string, then use it.
arunas_t
2010-05-27 16:04:16
I tried, but \x5E was written in doc file as it is, instead of writing ^. Please help.
Safiullah
2010-05-28 10:50:08