Bookmark.MoveEnd(Object, Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Moves the ending character position of a Bookmark control.
public int MoveEnd (ref object unit, ref object count);
abstract member MoveEnd : obj * obj -> int
Public Function MoveEnd (Optional ByRef unit As Object, Optional ByRef count As Object) As Integer
Parameters
- unit
- Object
The unit by which to move the ending character position.
- count
- Object
The number of units to move. If this number is positive, the ending character position is moved forward in the document. If this number is negative, the end is moved backward. If the ending position overtakes the starting position, the range collapses and both character positions move together. The default value is 1.
Returns
The number of units the Bookmark control actually moved, or it returns 0 (zero) if the move was unsuccessful.
Examples
The following code example adds a Bookmark control with text to the first paragraph and displays the last word of the bookmark in a message box. The code then calls the MoveEnd method and displays the last word of the bookmark in a new message box.
This example is for a document-level customization.
private void BookmarkMoveEnd()
{
this.Paragraphs[1].Range.InsertParagraphBefore();
this.Paragraphs[1].Range.Text = "This is sample text.";
Microsoft.Office.Tools.Word.Bookmark bookmark1 =
this.Controls.AddBookmark(this.Paragraphs[1].Range.Words[3],
"bookmark1");
object Unit = Word.WdUnits.wdWord;
object Count = 1;
MessageBox.Show("Last word of bookmark prior to calling MoveEnd: "
+ bookmark1.Words.Last.Text);
bookmark1.MoveEnd(ref Unit, ref Count);
MessageBox.Show("Last word of bookmark after calling MoveEnd: "
+ bookmark1.Words.Last.Text);
}
Private Sub BookmarkMoveEnd()
Me.Paragraphs(1).Range.InsertParagraphBefore()
Me.Paragraphs(1).Range.Text = "This is sample text."
Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
Me.Controls.AddBookmark(Me.Paragraphs(1).Range.Words(3), _
"Bookmark1")
MessageBox.Show("Last word of bookmark prior to calling MoveEnd: " _
& Bookmark1.Words.Last.Text)
Bookmark1.MoveEnd(Word.WdUnits.wdWord, 1)
MessageBox.Show("Last word of bookmark after calling MoveEnd: " _
& Bookmark1.Words.Last.Text)
End Sub
Remarks
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.