다음을 통해 공유


Bookmark.GoToPrevious 메서드

이전 항목의 시작 위치 또는 What 인수가 지정하는 Bookmark 컨트롤 내의 위치를 참조하는 Range 개체를 가져옵니다.

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

구문

‘선언
Function GoToPrevious ( _
    What As WdGoToItem _
) As Range
Range GoToPrevious(
    WdGoToItem What
)

매개 변수

반환 값

형식: Microsoft.Office.Interop.Word.Range
이전 항목의 시작 위치 또는 What 인수가 지정하는 Bookmark 컨트롤 내의 위치를 참조하는 Range 개체입니다.

예제

다음 코드 예제에서는 텍스트와 텍스트가 있는 Bookmark 컨트롤을 문서에 추가한 다음 주석을 해당 텍스트에 추가합니다. GoToNext와 GoToPrevious를 사용하면 주석 위치가 메시지 상자에 표시됩니다.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

Private Sub BookmarkGoToNext()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Text = "This is the first paragraph."

    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(2).Range, "Bookmark1")
    Bookmark1.Text = "This is original text of the bookmark."

    Dim commentText As Object = "This is some comment text."
    Me.Paragraphs(1).Range.Comments.Add(Me.Paragraphs(1).Range _
        .Words(4), commentText)
    Bookmark1.Words.First.Comments.Add(Bookmark1.Words.First, _
        commentText)
    Bookmark1.InsertBefore("Text inserted before bookmark. ")
    Bookmark1.InsertAfter(" Text inserted after bookmark.")

    Dim range1 As Word.Range = Bookmark1.GoToNext( _
        Word.WdGoToItem.wdGoToComment)
    Dim range2 As Word.Range = Bookmark1.GoToPrevious( _
        Word.WdGoToItem.wdGoToComment)

    MessageBox.Show("Using GoToNext, the comment is " & _
        "at position " & range1.Start.ToString & vbLf & _
        "Using GoToPrevious, the comment is at position " & _
        range2.Start.ToString)

End Sub
private void BookmarkGoToNext()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Text = "This is the first paragraph.";
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
       this.Controls.AddBookmark(this.Paragraphs[2].Range,
       "bookmark1");
    bookmark1.Text = "This is original text of the bookmark.";

    object commentText = "This is some comment text.";
    this.Paragraphs[1].Range.Comments.Add(this.Paragraphs[1]
        .Range.Words[4], ref commentText);
    bookmark1.Words.First.Comments.Add(bookmark1.Words.First,
        ref commentText);

    bookmark1.InsertBefore("Text inserted before bookmark. ");
    bookmark1.InsertAfter(" Text inserted after bookmark.");

    Word.Range range1 = bookmark1.GoToNext(Word.WdGoToItem.wdGoToComment);
    Word.Range range2 = bookmark1.GoToPrevious(Word.WdGoToItem.wdGoToComment);

    MessageBox.Show("Using GoToNext, the comment is at position " 
        + range1.Start.ToString() + "\n" +
        "Using GoToPrevious, the comment is at position "
        + range2.Start.ToString());
}

.NET Framework 보안

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

참고 항목

참조

Bookmark 인터페이스

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