Creating Shapes

An AutoShape is a Shape object that represents a built-in drawing. To add a new AutoShape object, we use the AddShape method, whose syntax is:

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

The parameter Type is the type of AutoShape to create. It can be any one of the

MsoAutoShapeType constants in Table A-1.

The required parameters Left and Top specify the position (in points as a Single) of the upper-left corner of the bounding box for the AutoShape object, measured relative to the upper-left corner of the container object (chart, chart sheet, or worksheet).

The Width and Height parameters specify the width and height (in points as a Single) of the bounding box for the AutoShape. Note that the type of a Shape object can be changed by setting the AutoShapeType property.

Table A-1. MsoAutoShapeType Constants

and Values)

msoShape16pointStar (94)

msoShapeFlowchartCard (75)

msoShapeLineCallout2BorderandAccentBar (122)

msoShape24pointStar (95)

msoShapeFlowchartCollate (79)

msoShapeLineCallout2NoBorder (118)

msoShape32pointStar (96)

msoShapeFlowchartConnector (73)

msoShapeLineCallout3 (111)

msoShape4pointStar (91)

msoShapeFlowchartData (64)

msoShapeLineCallout3AccentBar (115)

msoShape5pointStar (92)

msoShapeFlowchartDecision (63)

msoShapeLineCallout3BorderandAccentBar (123)

msoShape8pointStar (93)

msoShapeFlowchartDelay (84)

msoShapeLineCallout3NoBorder (119)

msoShapeActionButtonBackorPrevious (129)

msoShapeFlowchartDirectAccessStorage (87)

msoShapeLineCallout4 (112)

msoShapeActionButtonBeginning (131)

msoShapeFlowchartDisplay (88)

msoShapeLineCallout4AccentBar (116)

msoShapeActionButtonCustom (125)

msoShapeFlowchartDocument (67)

msoShapeLineCallout4BorderandAccentBar (124)

msoShapeActionButtonDocument (134)

msoShapeFlowchartExtract (81)

msoShapeLineCallout4NoBorder (120)

msoShapeActionButtonEnd (132)

msoShapeFlowchartInternalStorage (66)

msoShapeMixed (-2)

msoShapeActionButtonF orwardorNext (130)

msoShapeFlowchartMagneticDisk (86)

msoShapeMoon (24)

msoShapeActionButtonHelp (127)

msoShapeFlowchartManualInput (71)

msoShapeNoSymbol (19)

msoShapeActionButtonHome (126)

msoShapeFlowchartManualOperation (72)

msoShapeNotchedRightArrow (50)

msoShapeActionButtonInformation (128)

msoShapeFlowchartMerge (82)

msoShapeNotPrimitive (138)

msoShapeActionButtonMovie (136)

msoShapeFlowchartMultidocument (68)

msoShapeOctagon (6)

msoShapeActionButtonReturn (133)

msoShapeFlowchartOffpageConnector (74)

msoShapeOval (9)

msoShapeActionButtonSound (135)

msoShapeFlowchartOr (78)

msoShapeOvalCallout (107)

msoShapeArc (25)

msoShapeFlowchartPredefinedProcess (65)

msoShapeParallelogram (2)

msoShapeBalloon (137)

msoShapeFlowchartPreparation (70)

msoShapePentagon (51)

msoShapeBentArrow (41)

msoShapeFlowchartProcess (61)

msoShapePlaque (28)

msoShapeBentUpArrow (44)

msoShapeFlowchartPunchedTape (76)

msoShapeQuadArrow (39)

msoShapeBevel (15)

msoShapeFlowchartSequentialAccessStorage (85)

msoShapeQuadArrowCallout (59)

msoShapeBlockArc (20)

msoShapeFlowchartSort (80)

msoShapeRectangle (1)

msoShapeCan (13)

msoShapeFlowchartStoredData (83)

msoShapeRectangularCallout (105)

msoShapeChevron (52)

msoShapeFlowchartSummingJunction (77)

msoShapeRegularPentagon (12)

msoShapeCircularArrow (60)

msoShapeFlowchartTerminator (69)

msoShapeRightArrow (33)

msoShapeCloudCallout (108)

msoShapeFoldedCorner (16)

msoShapeRightArrowCallout (53)

msoShapeCross (11)

msoShapeHeart (21)

msoShapeRightBrace (32)

msoShapeCube (14)

msoShapeHexagon (10)

msoShapeRightBracket (30)

msoShapeCurvedDownArrow (48)

msoShapeHorizontalScroll (102)

msoShapeRightTriangle (8)

msoShapeCurvedDownRibbon (100)

msoShapelsoscelesTriangle (7)

msoShapeRoundedRectangle (5)

msoShapeCurvedLeftArrow (46)

msoShapeLeftArrow (34)

msoShapeRoundedRectangularCallout (106)

msoShapeCurvedRightArrow (45)

msoShapeLeftArrowCallout (54)

msoShapeSmileyFace (17)

msoShapeCurvedUpArrow (47)

msoShapeLeftBrace (31)

msoShapeStripedRightArrow (49)

msoShapeCurvedUpRibbon (99)

msoShapeLeftBracket (29)

msoShapeSun (23)

msoShapeDiamond (4)

msoShapeLeftRightArrow (37)

msoShapeTrapezoid (3)

msoShapeDonut (18)

msoShapeLeftRightArrowCallout (57)

msoShapeUpArrow (35)

msoShapeDoubleBrace (27)

msoShapeLeftRightUpArrow (40)

msoShapeUpArrowCallout (55)

msoShapeDoubleBracket (26)

msoShapeLeftUpArrow (43)

msoShapeUpDownArrow (38)

msoShapeDoubleWave (104)

msoShapeLightningBolt (22)

msoShapeUpDownArrowCallout (58)

msoShapeDownArrow (36)

msoShapeLineCallout1 (109)

msoShapeUpRibbon (97)

msoShapeDownArrowCallout (56)

msoShapeLineCallout1AccentBar (113)

msoShapeUTurnArrow (42)

msoShapeDownRibbon (98)

msoShapeLineCallout1BorderandAccentBar (121)

msoShapeVerticalScroll (101)

msoShapeExplosion1 (89)

msoShapeLineCallout1NoBorder (117)

msoShapeWave (103)

msoShapeExplosion2 (90)

msoShapeLineCallout2 (110)

msoShapeFlowchartAlternateProcess (62)

msoShapeLineCallout2AccentBar (114)

The short program in Example A-1 will display each AutoShape, along with its AutoShapeType, for 0.5 seconds. (It should be run on a blank worksheet. You can interrupt this program at any time by striking Ctrl-Break.) The Delay subroutine that it calls is shown in Example A-2.

0 0

Responses

  • sarah
    How to use msoshapearc vba?
    3 months ago

Post a comment