Shape.Select 方法 (Project)

选择形状。

语法

表达式选择 “ (替换)

表达 一个代表 Shape 对象的变量。

参数

名称 必需/可选 数据类型 说明
Replace 可选 Variant True 将当前选定内容替换为新选定内容。 False 会将新选定内容添加到当前选定内容。 默认值为 True
Replace 可选 Variant

返回值

Nothing

示例

以下示例创建三个形状,然后选择每个形状。 由于第二个和第三个选择添加到第一个选定区域,因此将选中所有三个形状, (见图 1) 。

Sub SelectShapes()
    Dim theReport As Report
    Dim shp1 As shape
    Dim shp2 As shape
    Dim shp3 As shape
    Dim reportName As String
    
    reportName = "Select Report"
    
    Set theReport = ActiveProject.Reports.Add(reportName)
    Set shp1 = theReport.Shapes.AddShape(msoShapeActionButtonHelp, 20, 50, 20, 30)
    Set shp2 = theReport.Shapes.AddShape(msoShapeBalloon, 100, 50, 30, 50)
    Set shp3 = theReport.Shapes.AddShape(msoShapeWave, 140, 50, 30, 50)
            
    shp1.Select
    shp2.Select False
    shp3.Select False
End Sub

图 1. 使用 Select 方法添加到选定内容

使用 Select 方法添加选择

另请参阅

形状对象

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。