我正在尝试检查“单词替换文本列表”中是否存在单词“ CU”。我在interop.Excel和VBA中找到了,我们有AutoCorrect.ReplacementList。但是在interop.Word中不是。
所以我的问题是如何通过C#检查Word替换列表中是否存在“ CU”。感谢您的收看。
Microsoft.Office.Interop.Word.Application oWord = (Microsoft.Office.Interop.Word.Application)w;
_activeDoc = oWord.ActiveDocument;
oWord.Application.AutoCorrect.ReplaceText .......??????
要获取Word中自动更正列表的列表,请使用AutoCorrect.Entries
集合。 Name
属性返回“快捷方式”,Value
属性返回替换“快捷方式”的文本。
string acName = "";
string acValue = "";
bool foundit = false;
Word.AutoCorrectEntries ACs = wdApp.AutoCorrect.Entries;
foreach (Word.AutoCorrectEntry AC in ACs)
{
acName = AC.Name;
acValue = AC.Value;
Debug.Print("Name: {0}, Value: {1}", acName, acValue);
if (acName == "CU")
{
foundit = true;
break;
}
}
if (foundit)
{
MessageBox.Show("Found it: " + acValue);
}
else MessageBox.Show("Not present");