Shape オブジェクト (Project)

グラフ、レポート テーブル、テキスト ボックス、フリーフォーム図面、図など、Project レポート内のオブジェクトを表します。

注釈

Shape オブジェクトは、レポート内のすべての図形を含む Shapes コレクションのメンバーです。

注:

Shape オブジェクトのマクロ記録は実装されていません。 つまり、Project でマクロを記録し、図形を手動で追加したり、図形要素を編集したりすると、図形を追加および操作する手順は記録されません。

図形を表す 3 つのオブジェクトがあります。 Shapes コレクションは、ドキュメント上のすべての図形を表します。 ShapeRange オブジェクト。ドキュメント上の図形の指定されたサブセットを表します (たとえば、 ShapeRange オブジェクトは、ドキュメント上の図形を 1 と 4 で表したり、ドキュメント上で選択したすべての図形を表したりできます)。と、ドキュメント上の 1 つの図形を表す Shape オブジェクト。 複数の図形を同時に操作する場合、または選択範囲内の図形を操作する場合は、 ShapeRange コレクションを使用します。

を使用し Shapes(Index)Index は図形名またはインデックス番号で、1 つの Shape オブジェクトを返します。

次の例では、 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 は結果を示しています。ここで、[描画ツール] のリボンの [書式] タブを使用できるように図形が選択されていますが、アクティブなタブは [レポート ツール] の下の [デザイン] になっています。 図形が選択されていない場合、 DRAWING TOOLS[書式 ] タブは表示されません。

図 1. Shape オブジェクト モデルのテスト

Shape オブジェクト モデルのテスト

メソッド

名前
Apply
Copy
Cut
Delete
Duplicate
Flip
IncrementLeft
IncrementRotation
IncrementTop
PickUp
RerouteConnections
ScaleHeight
ScaleWidth
Select
SetShapesDefaultProperties
Ungroup
ZOrder

プロパティ

名前
Adjustments
AlternativeText
アプリケーション
AutoShapeType
BackgroundStyle
BlackWhiteMode
Callout
Chart
Child
ConnectionSiteCount
Connector
ConnectorFormat
Fill
Glow
GroupItems
HasChart
HasTable
Height
HorizontalFlip
ID
Left
Line
LockAspectRatio
名前
Nodes
Parent
ParentGroup
Reflection
Rotation
Shadow
ShapeStyle
SoftEdge
Table
TextEffect
TextFrame
TextFrame2
ThreeD
タイトル
Top
VerticalFlip
Vertices
Visible
Width
ZOrderPosition

関連項目

レポート オブジェクトグラフ オブジェクト

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。