更新 : 2007 年 11 月
指定された開始文字位置と終了文字位置を使用して Microsoft.Office.Interop.Word.Range を返します。
名前空間 : Microsoft.Office.Tools.Word
アセンブリ : Microsoft.Office.Tools.Word.v9.0 (Microsoft.Office.Tools.Word.v9.0.dll 内)
構文
'宣言
Public Function Range ( _
ByRef Start As Object, _
ByRef End As Object _
) As Range
'使用
Dim instance As Document
Dim Start As Object
Dim End As Object
Dim returnValue As Range
returnValue = instance.Range(Start, End)
public Range Range(
ref Object Start,
ref Object End
)
パラメータ
Start
型 : System.Object%開始文字位置。
End
型 : System.Object%終了文字位置。
戻り値
型 : Microsoft.Office.Interop.Word.Range
指定された開始文字位置と終了文字位置による Microsoft.Office.Interop.Word.Range。
解説
省略可能なパラメータ
省略可能なパラメータについては、「Office ソリューションの省略可能なパラメータについて」を参照してください。
例
Range メソッドを使用して "This is a line of text" という文字列を現在の文書に追加し、この文字列の最初の 7 文字だけを格納してある Microsoft.Office.Interop.Word.Range を取得するコード例を次に示します。
この例は、ドキュメント レベルのカスタマイズ用に作成されています。
Private Sub DocumentRange()
Me.Range(0, 0).Text = "This is a line of text. "
' Display only the first seven characters in the string.
Dim range2 As Word.Range = Me.Range(0, 7)
MessageBox.Show(range2.Text)
End Sub
private void DocumentRange()
{
// Add a string to the document.
object start = 0;
object end = 0;
string newText = "This is a line of text. ";
Word.Range range1 = this.Range(ref start, ref end);
range1.Text = newText;
// Display only the first seven characters in the string.
end = 7;
Word.Range range2 = this.Range(ref start, ref end);
MessageBox.Show("The first seven characters: " +
range2.Text);
}
アクセス許可
- 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。