【发布时间】:2022-10-05 02:12:32
【问题描述】:
我正在制作一个 Windows 窗体应用程序,它将接受用户输入,并在提交时打开一个 word 模板并从 windows 窗体中查找和替换日期到 word 文档。我希望替换的文本带有下划线。我正在使用从另一个用户那里找到的功能,但我不确定如何设置格式。这是我正在使用的功能:
private void FindAndReplace(Microsoft.Office.Interop.Word.Application wordApp, object toFindText, object replaceWithText)
{
object matchCase = true;
object matchwholeWord = true;
object matchwildCards = false;
object matchSoundLike = false;
object nmatchAllforms = false;
object forward = true;
object format = false;
object matchKashida = false;
object matchDiactitics = false;
object matchAlefHamza = false;
object matchControl = false;
object read_only = false;
object visible = true;
object replace = -2;
object wrap = 1;
wordApp.Selection.Find.Execute(ref toFindText, ref matchCase,
ref matchwholeWord, ref matchwildCards, ref matchSoundLike,
ref nmatchAllforms, ref forward,
ref wrap, ref format, ref replaceWithText,
ref replace, ref matchKashida,
ref matchDiactitics, ref matchAlefHamza,
ref matchControl);
}
我可以看到有一个对象格式 = false,但是当我检查文档时,我看不到如何设置格式选项。
【问题讨论】:
标签: c# winforms ms-word office-interop office-automation