应用于 CanvasShapes 对象的 AddShape 方法。
在画布上添加一个“自选图形”对象。返回一个代表该“自选图形”对象的 Shape 对象,并将其添加到 CanvasShapes 集合。
expression.AddShape(Type, Left, Top, Width, Height)
expression 必需。该表达式返回一个 CanvasShapes 对象。
Type Long 类型,必需。要返回的图形类型。可以是任何 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 |
Left Single 类型,必需。“自选图形”对象左侧边缘的位置,以磅为单位。
Top Single 类型,必需。“自选图形”对象上部边缘的位置,以磅为单位。
Width Single 类型,必需。“自选图形”对象的宽度,以磅为单位。
Height Single 类型,必需。“自选图形”对象的高度,以磅为单位。
在文档中添加一个“自选图形”对象。返回一个代表该“自选图形”对象的 Shape 对象,并将其添加到 Shapes 集合。
expression.AddShape(Type, Left, Top, Width, Height, Anchor)
expression 必需。该表达式返回一个 Shapes 对象。
Type Long 类型,必需。要返回的图形类型。可以是任何 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 |
Left Single 类型,必需。“自选图形”对象左侧边缘的位置,以磅为单位。
Top Single 类型,必需。“自选图形”对象上部边缘的位置,以磅为单位。
Width Single 类型,必需。“自选图形”对象的宽度,以磅为单位。
Height Single 类型,必需。“自选图形”对象的高度,以磅为单位。
Anchor Variant 类型,可选。代表该“自选图形”所连接文本的 Range 对象。如果指定 Anchor,则锁定标记位于锁定区域第一段的起始位置。如果忽略该参数,则 Word 将自动选定锁定区域,而自选图形将相对于页面的上部和左侧边缘进行定位。
要改变所添加的“自选图形”类型,可设置其 AutoShapeType 属性。
本示例在活动文档中创建新的画布,并在画布上添加一个圆形。
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
本示例在新文档中添加一个红色矩形。
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