グラフ、レポート テーブル、テキスト ボックス、フリーフォームの描画、画像など、Project レポート内のオブジェクトを表します。
注釈
Shape オブジェクトは、レポートのすべての図形を含む Shapes コレクションのメンバーです。
注:
Shape オブジェクトのマクロの記録が実装されていません。 つまり、Project でマクロを記録して手動で図形を追加したり、図形要素を編集したりすると、図形を追加および操作する手順は記録されません。
図形を表すオブジェクトには次の 3 つがあります。 図形 コレクションは、ドキュメント上のすべての図形を表します。 ShapeRange オブジェクト。ドキュメント上の図形の指定されたサブセットを表します (たとえば、 ShapeRange オブジェクトは、ドキュメント上の図形 1 と 4 を表したり、ドキュメント上の選択されたすべての図形を表したりできます)。および Shape オブジェクト (ドキュメント上の 1 つの図形を表します)。 複数の図形を同時に操作する場合や、選択範囲内の図形を操作する場合は、 ShapeRange コレクションを使用します。
1 つの Shape オブジェクトを返すには、Shapes(Index) を使用します。ここで、Index は図形名またはインデックス番号です。
例
次の例では、 TestTextShape マクロを使用してテキスト ボックス図形を作成し、いくつかのテキストを追加して、図形のスタイル、塗りつぶし、線、影、反射のプロパティを変更しています。 FlipShape マクロは、図形を上から下に反転します。
Sub TestTextShape()
Dim theReport As Report
Dim textShape As Shape
Dim reportName As String
reportName = "Simple scalar chart"
Set theReport = ActiveProject.Reports(reportName)
Set textShape = theReport.Shapes.AddTextbox(msoTextOrientationHorizontal, 30, 30, 300, 100)
textShape.Name = "TestTextBox"
textShape.TextFrame2.TextRange.Characters.Text = "This is a test. It's only a test. " _
& "If it had been real information, there would be some real text here."
textShape.TextFrame2.TextRange.Characters(1, 15).ParagraphFormat.FirstLineIndent = 0
' Set the font for the first 15 characters to dark blue bold.
With textShape.TextFrame2.TextRange.Characters(1, 15).Font
.Fill.Visible = msoTrue
.Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent5
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Bold = msoTrue
End With
textShape.ShapeStyle = msoShapeStylePreset42
With textShape.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 0)
.Transparency = 0
'.Solid
End With
With textShape.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
End With
textShape.Shadow.Type = msoShadow22
textShape.Reflection.Type = msoReflectionType3
End Sub
Sub FlipShape()
Dim theReport As Report
Dim theShape As Shape
Dim reportName As String
Dim shapeName As String
reportName = "Simple scalar chart"
shapeName = "TestTextBox"
Set theShape = ActiveProject.Reports(reportName).Shapes(shapeName)
theShape.Flip msoFlipVertical
theShape.Select
End Sub
図 1 は、図形が選択されて [描画ツール] の下の [書式] タブが使用可能になるが、アクティブなタブが [レポート ツール] の下の [デザイン] になっている結果を示しています。 図形が選択されていない場合、[ 描画ツール ] と [ 書式 ] タブは表示されません。
図 1. Shape オブジェクト モデルのテスト
メソッド
| 名前 |
|---|
| Apply |
| Copy |
| Cut |
| Delete |
| Duplicate |
| Flip |
| IncrementLeft |
| IncrementRotation |
| IncrementTop |
| PickUp |
| RerouteConnections |
| ScaleHeight |
| ScaleWidth |
| Select |
| SetShapesDefaultProperties |
| Ungroup |
| ZOrder |
プロパティ
関連項目
サポートとフィードバック
Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。