0

C# で単語アドインを作成するのは初めてで、文字列とフォントの色に関する質問があります。Word 2010 のセルの既存の文字列に赤い文字列を追加したいのですが、次のようになります。

 Word.Range r = document.Range(0, 0);
 r.Text = "text";
 r.Font.ColorIndex = WdColorIndex.wdRed;
 tbl.Cell(RowNum, RightColumn).Range.Text += r; 

何か案は?

4

2 に答える 2

0

Well, I figured something out, I did this:

 int TblRng = tbl.Cell(RowNum,   RightColumn).Range.End;
 Range r = document.Range(TblRng-1, TblRng+1);
 r.Text = Final;
 r.Font.ColorIndex = WdColorIndex.wdRed;

int TblRng = tbl.Cell(RowNum, RightColumn).Range.End; - this defined the new range at the end of the location where I needed to add the red string.

于 2013-07-11T22:02:10.173 に答える
0

既存の文字列を新しい赤に置き換えたい場合は、次のコードを使用します

 object findText = stringText;
                        if (Range.Find.Execute(ref findText))
                        {
                            Range.Text = NewString; // replace old string with New
                            Range.Font.Color = WdColor.wdColorRed; // Set color of the string
                        } 
于 2020-07-23T03:30:26.110 に答える