0
我試圖用文本替換這個上標,但是當我嘗試我得到屬性或索引器的錯誤'Microsoft.Office.Interop.Word.Find.Replacement' cannot be assigned to - -it is read only
。對不起,我只是處理word文檔的新內容。替換引用編號
wordDoc.ActiveWindow.Selection.Find.Font.Superscript = -1;
object forward = true;
object wrap = WdFindWrap.wdFindStop;
object format = true;
object matchCase = false;
object matchWholeWord = false;
object matchWildcards = false;
object matchSoundsLike = false;
object matchAllWordForms = false;
// Search all numeric superscripts
while (wordDoc.ActiveWindow.Selection.Find.Execute(ref missing, ref matchCase, ref matchWholeWord, ref matchWildcards, ref matchSoundsLike, ref matchAllWordForms, ref forward, ref wrap, ref format, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing))
{
// Look for Numbered References
if (Regex.IsMatch((wordDoc.ActiveWindow.Selection.Text).Trim(), @"^(\d+|\d+.?\d+?)$"))
{
object reference = wordDoc.ActiveWindow.Selection.Range;
string refNo = Regex.Match((wordDoc.ActiveWindow.Selection.Text).Trim(), @"^(\d+|\d+.?\d+?)$").Value.ToString();
MessageBox.Show(refNo);
object replaceAll = Word.WdReplace.wdReplaceOne;
wordDoc.ActiveWindow.Selection.Find.Text = refNo;
wordDoc.ActiveWindow.Selection.Find.ClearFormatting();
wordDoc.ActiveWindow.Selection.Find.Replacement = "Here";
嘗試添加'。文本property'到問題行,以這樣的方式'wordDoc.ActiveWindow.Selection.Find.Replacement.Text = 「這裏」;' –
哦..它的工作!謝謝..! –
嗨再次..我即將更換refno的麻煩。它只替換所有內容而不是上標。即使是段落中的數字。它可以過濾的方式,只有上標是唯一改變的? –