DocumentBase.Words 屬性
取得 Microsoft.Office.Interop.Word.Words 集合,表示文件中的所有文字。
命名空間: Microsoft.Office.Tools.Word
組件: Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)
語法
'宣告
Public ReadOnly Property Words As Words
public Words Words { get; }
屬性值
型別:Microsoft.Office.Interop.Word.Words
Microsoft.Office.Interop.Word.Words 集合,表示文件中的所有文字。
備註
在文件中的標點符號和段落標記都包含在 Microsoft.Office.Interop.Word.Words 集合內。
範例
下列程式碼範例會加入一行文字至文件中,然後使用 Words 屬性將文件中的第一個字設為藍色。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。
Private Sub DocumentWords()
Dim start As Object = 0
Dim [end] As Object = 0
Dim range1 As Word.Range = Me.Range(start, [end])
range1.Text = "This is the first sentence in the document."
Me.Words.First.Font.Color = Word.WdColor.wdColorBlue
End Sub
private void DocumentWords()
{
object start = 0;
object end = 0;
Word.Range range1 = this.Range(ref start, ref end);
range1.Text = "This is the first sentence in the document.";
this.Words.First.Font.Color = Word.WdColor.wdColorBlue;
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。