使用 C# 在 Word 中插入符号 [英] InsertSymbol in Word using C#

查看:79
本文介绍了使用 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.

这篇关于使用 C# 在 Word 中插入符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆