返回介绍

AddShape 方法

发布于 2019-09-29 09:53:30 字数 14837 浏览 1836 评论 0 收藏 0

全部显示

应用于 CanvasShapes 对象的 AddShape 方法。

在画布上添加一个“自选图形”对象。返回一个代表该“自选图形”对象的 Shape 对象,并将其添加到 CanvasShapes 集合。

expression.AddShape(Type, Left, Top, Width, Height)

expression 必需。该表达式返回一个 CanvasShapes 对象。

TypeLong 类型,必需。要返回的图形类型。可以是任何 MsoAutoShapeType 常量。

MsoAutoShapeType 可以是下列 MsoAutoShapeType 常量之一:
msoShapeFlowchartDirectAccessStorage
msoShapeFlowchartDocument
msoShapeFlowchartInternalStorage
msoShapeFlowchartManualInput
msoShapeFlowchartMerge
msoShapeFlowchartOffpageConnector
msoShapeFlowchartPredefinedProcess
msoShapeFlowchartProcess
msoShapeLeftBracket
msoShapeFlowchartConnector
msoShapeFlowchartData
msoShapeFlowchartDecision
msoShapeFlowchartDelay
msoShapeFlowchartDisplay
msoShapeFlowchartExtract
msoShapeFlowchartMagneticDisk
msoShapeFlowchartManualOperation
msoShapeFlowchartMultidocument
msoShapeFlowchartOr
msoShapeFlowchartPreparation
msoShapeFlowchartPunchedTape
msoShapeFlowchartSequentialAccessStorage
msoShapeFlowchartSort
msoShapeFlowchartStoredData
msoShapeFlowchartSummingJunction
msoShapeFlowchartTerminator
msoShapeFoldedCorner
msoShapeHeart
msoShapeHexagon
msoShapeHorizontalScroll
msoShapeIsoscelesTriangle
msoShapeLeftArrow
msoShapeLeftArrowCallout
msoShapeLeftBrace
msoShapeLeftRightArrow
msoShapeLeftRightArrowCallout
msoShapeLeftRightUpArrow
msoShapeLeftUpArrow
msoShapeLightningBolt
msoShapeLineCallout1
msoShapeLineCallout1AccentBar
msoShapeLineCallout1BorderandAccentBar
msoShapeLineCallout1NoBorder
msoShapeLineCallout2
msoShapeLineCallout2AccentBar
msoShapeLineCallout2BorderandAccentBar
msoShapeLineCallout2NoBorder
msoShapeLineCallout3
msoShapeLineCallout3AccentBar
msoShapeLineCallout3BorderandAccentBar
msoShapeLineCallout3NoBorder
msoShapeLineCallout4
msoShapeLineCallout4AccentBar
msoShapeLineCallout4BorderandAccentBar
msoShapeLineCallout4NoBorder
msoShapeMixed
msoShapeMoon
msoShapeNoSymbol
msoShapeNotchedRightArrow
msoShapeNotPrimitive
msoShapeOctagon
msoShapeOval
msoShapeOvalCallout
msoShapeParallelogram
msoShapePentagon
msoShapePlaque
msoShapeQuadArrow
msoShapeQuadArrowCallout
msoShapeRectangle
msoShapeRectangularCallout
msoShapeRegularPentagon
msoShapeRightArrow
msoShapeRightArrowCallout
msoShapeRightBrace
msoShapeRightBracket
msoShapeRightTriangle
msoShapeRoundedRectangle
msoShapeRoundedRectangularCallout
msoShapeSmileyFace
msoShapeStripedRightArrow
msoShapeSun
msoShapeTrapezoid
msoShapeUpArrow
msoShapeUpArrowCallout
msoShapeUpDownArrow
msoShapeUpDownArrowCallout
msoShapeUpRibbon
msoShapeUTurnArrow
msoShapeVerticalScroll
msoShapeWave
msoShape16pointStar
msoShape24pointStar
msoShape32pointStar
msoShape4pointStar
msoShape5pointStar
msoShape8pointStar
msoShapeActionButtonBackorPrevious
msoShapeActionButtonBeginning
msoShapeActionButtonCustom
msoShapeActionButtonDocument
msoShapeActionButtonEnd
msoShapeActionButtonForwardorNext
msoShapeActionButtonHelp
msoShapeActionButtonHome
msoShapeActionButtonInformation
msoShapeActionButtonMovie
msoShapeActionButtonReturn
msoShapeActionButtonSound
msoShapeArc
msoShapeBalloon
msoShapeBentArrow
msoShapeBentUpArrow
msoShapeBevel
msoShapeBlockArc
msoShapeCan
msoShapeChevron
msoShapeCircularArrow
msoShapeCloudCallout
msoShapeCross
msoShapeCube
msoShapeCurvedDownArrow
msoShapeCurvedDownRibbon
msoShapeCurvedLeftArrow
msoShapeCurvedRightArrow
msoShapeCurvedUpArrow
msoShapeCurvedUpRibbon
msoShapeDiamond
msoShapeDonut
msoShapeDoubleBrace
msoShapeDoubleBracket
msoShapeDoubleWave
msoShapeDownArrow
msoShapeDownArrowCallout
msoShapeDownRibbon
msoShapeExplosion1
msoShapeExplosion2
msoShapeFlowchartAlternateProcess
msoShapeFlowchartCard
msoShapeFlowchartCollate

LeftSingle 类型,必需。“自选图形”对象左侧边缘的位置,以磅为单位。

TopSingle 类型,必需。“自选图形”对象上部边缘的位置,以磅为单位。

WidthSingle 类型,必需。“自选图形”对象的宽度,以磅为单位。

HeightSingle 类型,必需。“自选图形”对象的高度,以磅为单位。

应用于 Shapes 对象的 AddShape 方法。

在文档中添加一个“自选图形”对象。返回一个代表该“自选图形”对象的 Shape 对象,并将其添加到 Shapes 集合。

expression.AddShape(Type, Left, Top, Width, Height, Anchor)

expression 必需。该表达式返回一个 Shapes 对象。

TypeLong 类型,必需。要返回的图形类型。可以是任何 MsoAutoShapeType 常量。

MsoAutoShapeType 可以是下列 MsoAutoShapeType 常量之一:
msoShapeFlowchartDirectAccessStorage
msoShapeFlowchartDocument
msoShapeFlowchartInternalStorage
msoShapeFlowchartManualInput
msoShapeFlowchartMerge
msoShapeFlowchartOffpageConnector
msoShapeFlowchartPredefinedProcess
msoShapeFlowchartProcess
msoShapeLeftBracket
msoShapeFlowchartConnector
msoShapeFlowchartData
msoShapeFlowchartDecision
msoShapeFlowchartDelay
msoShapeFlowchartDisplay
msoShapeFlowchartExtract
msoShapeFlowchartMagneticDisk
msoShapeFlowchartManualOperation
msoShapeFlowchartMultidocument
msoShapeFlowchartOr
msoShapeFlowchartPreparation
msoShapeFlowchartPunchedTape
msoShapeFlowchartSequentialAccessStorage
msoShapeFlowchartSort
msoShapeFlowchartStoredData
msoShapeFlowchartSummingJunction
msoShapeFlowchartTerminator
msoShapeFoldedCorner
msoShapeHeart
msoShapeHexagon
msoShapeHorizontalScroll
msoShapeIsoscelesTriangle
msoShapeLeftArrow
msoShapeLeftArrowCallout
msoShapeLeftBrace
msoShapeLeftRightArrow
msoShapeLeftRightArrowCallout
msoShapeLeftRightUpArrow
msoShapeLeftUpArrow
msoShapeLightningBolt
msoShapeLineCallout1
msoShapeLineCallout1AccentBar
msoShapeLineCallout1BorderandAccentBar
msoShapeLineCallout1NoBorder
msoShapeLineCallout2
msoShapeLineCallout2AccentBar
msoShapeLineCallout2BorderandAccentBar
msoShapeLineCallout2NoBorder
msoShapeLineCallout3
msoShapeLineCallout3AccentBar
msoShapeLineCallout3BorderandAccentBar
msoShapeLineCallout3NoBorder
msoShapeLineCallout4
msoShapeLineCallout4AccentBar
msoShapeLineCallout4BorderandAccentBar
msoShapeLineCallout4NoBorder
msoShapeMixed
msoShapeMoon
msoShapeNoSymbol
msoShapeNotchedRightArrow
msoShapeNotPrimitive
msoShapeOctagon
msoShapeOval
msoShapeOvalCallout
msoShapeParallelogram
msoShapePentagon
msoShapePlaque
msoShapeQuadArrow
msoShapeQuadArrowCallout
msoShapeRectangle
msoShapeRectangularCallout
msoShapeRegularPentagon
msoShapeRightArrow
msoShapeRightArrowCallout
msoShapeRightBrace
msoShapeRightBracket
msoShapeRightTriangle
msoShapeRoundedRectangle
msoShapeRoundedRectangularCallout
msoShapeSmileyFace
msoShapeStripedRightArrow
msoShapeSun
msoShapeTrapezoid
msoShapeUpArrow
msoShapeUpArrowCallout
msoShapeUpDownArrow
msoShapeUpDownArrowCallout
msoShapeUpRibbon
msoShapeUTurnArrow
msoShapeVerticalScroll
msoShapeWave
msoShape16pointStar
msoShape24pointStar
msoShape32pointStar
msoShape4pointStar
msoShape5pointStar
msoShape8pointStar
msoShapeActionButtonBackorPrevious
msoShapeActionButtonBeginning
msoShapeActionButtonCustom
msoShapeActionButtonDocument
msoShapeActionButtonEnd
msoShapeActionButtonForwardorNext
msoShapeActionButtonHelp
msoShapeActionButtonHome
msoShapeActionButtonInformation
msoShapeActionButtonMovie
msoShapeActionButtonReturn
msoShapeActionButtonSound
msoShapeArc
msoShapeBalloon
msoShapeBentArrow
msoShapeBentUpArrow
msoShapeBevel
msoShapeBlockArc
msoShapeCan
msoShapeChevron
msoShapeCircularArrow
msoShapeCloudCallout
msoShapeCross
msoShapeCube
msoShapeCurvedDownArrow
msoShapeCurvedDownRibbon
msoShapeCurvedLeftArrow
msoShapeCurvedRightArrow
msoShapeCurvedUpArrow
msoShapeCurvedUpRibbon
msoShapeDiamond
msoShapeDonut
msoShapeDoubleBrace
msoShapeDoubleBracket
msoShapeDoubleWave
msoShapeDownArrow
msoShapeDownArrowCallout
msoShapeDownRibbon
msoShapeExplosion1
msoShapeExplosion2
msoShapeFlowchartAlternateProcess
msoShapeFlowchartCard
msoShapeFlowchartCollate

LeftSingle 类型,必需。“自选图形”对象左侧边缘的位置,以磅为单位。

TopSingle 类型,必需。“自选图形”对象上部边缘的位置,以磅为单位。

WidthSingle 类型,必需。“自选图形”对象的宽度,以磅为单位。

HeightSingle 类型,必需。“自选图形”对象的高度,以磅为单位。

AnchorVariant 类型,可选。代表该“自选图形”所连接文本的 Range 对象。如果指定Anchor,则锁定标记位于锁定区域第一段的起始位置。如果忽略该参数,则 Word 将自动选定锁定区域,而自选图形将相对于页面的上部和左侧边缘进行定位。

说明

要改变所添加的“自选图形”类型,可设置其 AutoShapeType 属性。

示例

当应用于 CanvasShapes 对象时。

本示例在活动文档中创建新的画布,并在画布上添加一个圆形。

Sub NewCanvasShape()
    Dim shpCanvas As Shape
    Dim shpCanvasShape As Shape

    'Add a new drawing canvas to the active document
    Set shpCanvas = ActiveDocument.Shapes.AddCanvas( _
        Left:=100, Top:=75, Width:=150, Height:=200)

    'Add a circle to the drawing canvas
    Set shpCanvasShape = shpCanvas.CanvasItems.AddShape( _
        Type:=msoShapeOval, Left:=25, Top:=25, _
        Width:=150, Height:=150)
End Sub

当应用于 Shapes 对象时。

本示例在新文档中添加一个红色矩形。

Sub NewShape()
    Dim docNew As Document

    'Create a new document and adds a shape
    Set docNew = Documents.Add
    docNew.Shapes.AddShape Type:=msoShapeRectangle, _
        Left:=50, Top:=50, Width:=100, Height:=200

    'Format the shape
    docNew.Shapes(1).Fill.ForeColor _
        .RGB = RGB(Red:=200, Green:=15, Blue:=95)
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文