Share via


DocumentBase.Range 메서드

지정된 시작 및 끝 문자 위치를 사용하여 Microsoft.Office.Interop.Word.Range를 반환합니다.

네임스페이스:  Microsoft.Office.Tools.Word
어셈블리:  Microsoft.Office.Tools.Word.v4.0.Utilities(Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

구문

‘선언
Public Function Range ( _
    ByRef start As Object, _
    ByRef end As Object _
) As Range
public Range Range(
    ref Object start,
    ref Object end
)

매개 변수

반환 값

형식: Microsoft.Office.Interop.Word.Range
지정된 시작 및 끝 문자 위치를 사용하는 Microsoft.Office.Interop.Word.Range

설명

선택적 매개 변수

선택적 매개 변수에 대한 자세한 내용은 Office 솔루션의 선택적 매개 변수를 참조하십시오.

예제

다음 코드 예제에서는 Range 메서드를 사용하여 현재 문서에 "This is a line of text" 문자열을 추가한 다음 문자열의 처음 7자만 포함된 Microsoft.Office.Interop.Word.Range를 가져옵니다. 이 예제를 사용하려면 문서 수준 프로젝트 ThisDocument 클래스에서 실행하십시오.

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);
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

DocumentBase 클래스

Microsoft.Office.Tools.Word 네임스페이스