I'm trying to check whether the word "CU" is exist in "word replace text list". I found out in interop.Excel and in VBA, we have AutoCorrect.ReplacementList. But in interop.Word is not.
So my question is how do i can check "CU" exist in Word replacement list by C#.
Thanks for your watching.
Microsoft.Office.Interop.Word.Application oWord = (Microsoft.Office.Interop.Word.Application)w;
_activeDoc = oWord.ActiveDocument;
oWord.Application.AutoCorrect.ReplaceText .......??????
To get a list of the AutoCorrect listing in Word use the AutoCorrect.Entries
collection. The Name
property returns the "shortcut", the Value
property the text that replaces the "shortcut".
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");