I'm creating a custom Microsoft Word mailmerge console application using C#. My only problem is trying to use the InsertSymbol command (from Microsoft.Office.Interop.Word). The purpose is to drop in a checked box symbol if the field value is true, and an empty box if the field value is false.
Microsoft has a definition of this command here with no concrete examples.
The way I have my command set up is this:
Object oFont = "Wingdings";
Object oUnicode = "t开发者_开发百科rue";
Object oBias = Word.WdFontBias.wdFontBiasDontCare;
oWord.Selection.InsertSymbol(254, ref oFont, ref oUnicode,ref oBias);
When I try to run that command, I get the error "This is not a valid number." There are not a lot of examples of this command online and I was hoping for some ideas. Thanks.
Thank you Robert for sharing this solution:
Object oFont = "Wingdings";
Object oUnicode = true;
Object oBias = Word.WdFontBias.wdFontBiasDontCare;
oWord.Selection.InsertSymbol(254, ref oFont, ref oUnicode,ref oBias);
It works well!
I found the answer. My problem was surrounding the value of oUnicode with quotes. I removed the quotes and now it works perfectly. I just wanted to let people know that it's working now.
Well, I did not get your code to Work. But then it hit me, that VSTO has a different perception of false and true: True is 1 (the number 1) so in the above code you should set:
oUnicode = 1;//NOT "true" and that IS 1 truth
Doing that I got the code working correctly. That also communicates with the error description ('not a valid number')
精彩评论