Bookmark.ShapeRange Property (2007 System)
Gets a ShapeRange collection that represents all the Shape objects in the Bookmark control.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property ShapeRange As ShapeRange
'Usage
Dim instance As Bookmark
Dim value As ShapeRange
value = instance.ShapeRange
[BrowsableAttribute(false)]
public ShapeRange ShapeRange { get; }
[BrowsableAttribute(false)]
public:
property ShapeRange^ ShapeRange {
ShapeRange^ get ();
}
public function get ShapeRange () : ShapeRange
Property Value
Type: ShapeRange
A ShapeRange collection that represents all the Shape objects in the Bookmark control.
Remarks
The shape range can contain drawings, shapes, pictures, OLE objects, ActiveX controls, text objects, and callouts.
Examples
The following code example adds a Bookmark control with text to the document and then uses the vertical and horizontal positions of the bookmark when creating a text box. It then displays the name of the ShapeRange within the bookmark in a message box.
This example is for a document-level customization.
Private Sub BookmarkShapeRange()
Me.Paragraphs(1).Range.InsertParagraphBefore()
Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
Bookmark1.Text = "This is sample bookmark text."
Dim vertical As Single = Bookmark1.Information(Microsoft.Office _
.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage)
Dim horizontal As Single = Bookmark1.Information(Microsoft.Office _
.Interop.Word.WdInformation.wdHorizontalPositionRelativeToPage)
Dim shape As Word.Shape = Me.Shapes.AddTextbox(Microsoft.Office.Core _
.MsoTextOrientation.msoTextOrientationHorizontal, vertical, _
horizontal, 50, 50)
MessageBox.Show(Bookmark1.ShapeRange.Name.ToString)
End Sub
private void BookmarkShapeRange()
{
this.Paragraphs[1].Range.InsertParagraphBefore();
Microsoft.Office.Tools.Word.Bookmark bookmark1 =
this.Controls.AddBookmark(this.Paragraphs[1].Range,
"bookmark1");
bookmark1.Text = "This is sample bookmark text.";
object myRange = bookmark1.Range;
object vertical = bookmark1.Information[Microsoft.Office
.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage];
object horizontal = bookmark1.Information[Microsoft.Office
.Interop.Word.WdInformation.wdHorizontalPositionRelativeToPage];
Word.Shape shape = this.Shapes.AddTextbox(Microsoft.Office.Core
.MsoTextOrientation.msoTextOrientationHorizontal, (float)vertical,
(float)horizontal, 50, 50, ref missing);
MessageBox.Show(bookmark1.ShapeRange.Name.ToString());
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.