使用 C# 在 Word 中插入符号
我正在使用 C# 创建自定义 Microsoft Word 邮件合并控制台应用程序.我唯一的问题是尝试使用 InsertSymbol 命令(来自 Microsoft.Office.Interop.Word).目的是如果字段值为真则放入一个复选框符号,如果字段值为假则放入一个空框.
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 = "true";
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.
我找到了答案.我的问题是用引号包围 oUnicode 的值.我删除了引号,现在它可以完美运行.我只是想让人们知道它现在正在发挥作用.
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.