MS 오피스 팁/Word

[Word/VBA] 도형 삽입 / Adding shapes

노하우저장소 2021. 5. 25.

문서 작업 시 도형을 사용하는 경우가 있을 수 있습니다.

관련 업무 자동화를 위해서는 도형 삽입과 상세 조정 방법의 VBA 코드를 알아야겠죠!

본 포스팅에서는 다양한 도형을 삽입하는 방법에 대해 상세히 알아보겠습니다.

 

도형 삽입 구문 (Syntax)

expression.AddShape( _Type_ , _Left_ , _Top_ , _Width_ , _Height_ )

예시)

ActiveDocument.Shapes.AddShape msoShapeRectangle, 50, 50, 100, 100
ActiveDocument.Shapes.AddShape 25, 50, 50, 100, 100

 

도형 Type Value

행렬의 숫자를 합하면 해당 도형의 Type Value가 됩니다. 

예) 20 + 16 = 36 (아래쪽 화살표, Block arrow that points down)

아래 코드로 한 번에 모든 도형을 삽입해 봤습니다.

Sub 도형다보기()

On Error Resume Next

shape = 1

For i = 1 To 10
    For j = 1 To 20
        ActiveDocument.Shapes.AddShape Shape, 100 + j * 20, 100 + i * 20, 15, 15
        Shape = Shape + 1
    Next
Next

End Sub

Value of msoShape Types

도형 전체 리스트

Name Value Description  한국어
msoShapeMixed -2 Return value only; indicates a combination of the other states.  
msoShapeRectangle 1 Rectangle  직사각형
msoShapeParallelogram 2 Parallelogram  평행 사변형
msoShapeTrapezoid 3 Trapezoid  사다리꼴
msoShapeDiamond 4 Diamond  다이아몬드
msoShapeRoundedRectangle 5 Rounded rectangle  사각형 : 둥근 모서리
msoShapeOctagon 6 Octagon  팔각형
msoShapeIsoscelesTriangle 7 Isosceles triangle  이등변 삼각형
msoShapeRightTriangle 8 Right triangle  직각 삼각형
msoShapeOval 9 Oval  타원
msoShapeHexagon 10 Hexagon  육각형
msoShapeCross 11 Cross  십자형
msoShapeRegularPentagon 12 Pentagon  오각형
msoShapeCan 13 Can  원통형
msoShapeCube 14 Cube  정육면체
msoShapeBevel 15 Bevel  사각형 : 빗면
msoShapeFoldedCorner 16 Folded corner  사각형 : 모서리 접힘
msoShapeSmileyFace 17 Smiley face  웃는 얼굴
msoShapeDonut 18 Donut  빈 원형
msoShapeNoSymbol 19 "No" symbol  기호 "허용 안됨"
msoShapeBlockArc 20 Block arc  막힌 원호
msoShapeHeart 21 Heart  하트
msoShapeLightningBolt 22 Lightning bolt  번개
msoShapeSun 23 Sun  해
msoShapeMoon 24 Moon  달
msoShapeArc 25 Arc  원호
msoShapeDoubleBracket 26 Double bracket  양쪽 대괄호
msoShapeDoubleBrace 27 Double brace  양족 중괄호
msoShapePlaque 28 Plaque  배지 (?)
msoShapeLeftBracket 29 Left bracket  왼쪽 대괄호
msoShapeRightBracket 30 Right bracket  오른쪽 대괄호
msoShapeLeftBrace 31 Left brace  왼쪽 중괄호
msoShapeRightBrace 32 Right brace 오른쪽 중괄호
msoShapeRightArrow 33 Block arrow that points right 화살표 : 오른쪽
msoShapeLeftArrow 34 Block arrow that points left 화살표 : 왼쪽
msoShapeUpArrow 35 Block arrow that points up 화살표 : 위쪽
msoShapeDownArrow 36 Block arrow that points down  화살표 : 아래쪽
msoShapeLeftRightArrow 37 Block arrow with arrowheads that point both left and right  화살표 : 왼쪽/오른쪽
msoShapeUpDownArrow 38 Block arrow that points up and down  화살표 : 위쪽/아래쪽
msoShapeQuadArrow 39 Block arrows that point up, down, left, and right  화살표 : 상/하/좌/우
msoShapeLeftRightUpArrow 40 Block arrow with arrowheads that point left, right, and up 화살표 : 상/좌/우
msoShapeBentArrow 41 Block arrow that follows a curved 90-degree angle. 화살표 : 굽음
msoShapeUTurnArrow 42 Block arrow forming a U shape  화살표 : U턴
msoShapeLeftUpArrow 43 Block arrow with arrowheads that point left and up  화살표 : 좌/상
msoShapeBentUpArrow 44 Block arrow that follows a sharp 90-degree angle. Points up by default.  화살표 : 위로 굽음
msoShapeCurvedRightArrow 45 Block arrow that curves right  
msoShapeCurvedLeftArrow 46 Block arrow that curves left  
msoShapeCurvedUpArrow 47 Block arrow that curves up  
msoShapeCurvedDownArrow 48 Block arrow that curves down  
msoShapeStripedRightArrow 49 Block arrow that points right with stripes at the tail  
msoShapeNotchedRightArrow 50 Notched block arrow that points right  
msoShapePentagon 51 Pentagon  
msoShapeChevron 52 Chevron  
msoShapeRightArrowCallout 53 Callout with arrow that points right  
msoShapeLeftArrowCallout 54 Callout with arrow that points left  
msoShapeUpArrowCallout 55 Callout with arrow that points up  
msoShapeDownArrowCallout 56 Callout with arrow that points down  
msoShapeLeftRightArrowCallout 57 Callout with arrowheads that point both left and right  
msoShapeUpDownArrowCallout 58 Callout with arrows that point up and down  
msoShapeQuadArrowCallout 59 Callout with arrows that point up, down, left, and right  
msoShapeCircularArrow 60 Block arrow that follows a curved 180-degree angle  
msoShapeFlowchartProcess 61 Process flowchart symbol  
msoShapeFlowchartAlternateProcess 62 Alternate process flowchart symbol  
msoShapeFlowchartDecision 63 Decision flowchart symbol  
msoShapeFlowchartData 64 Data flowchart symbol  
msoShapeFlowchartPredefinedProcess 65 Predefined process flowchart symbol  
msoShapeFlowchartInternalStorage 66 Internal storage flowchart symbol  
msoShapeFlowchartDocument 67 Document flowchart symbol  
msoShapeFlowchartMultidocument 68 Multi-document flowchart symbol  
msoShapeFlowchartTerminator 69 Terminator flowchart symbol  
msoShapeFlowchartPreparation 70 Preparation flowchart symbol  
msoShapeFlowchartManualInput 71 Manual input flowchart symbol  
msoShapeFlowchartManualOperation 72 Manual operation flowchart symbol  
msoShapeFlowchartConnector 73 Connector flowchart symbol  
msoShapeFlowchartOffpageConnector 74 Off-page connector flowchart symbol  
msoShapeFlowchartCard 75 Card flowchart symbol  
msoShapeFlowchartPunchedTape 76 Punched tape flowchart symbol  
msoShapeFlowchartSummingJunction 77 Summing junction flowchart symbol  
msoShapeFlowchartOr 78 "Or" flowchart symbol  
msoShapeFlowchartCollate 79 Collate flowchart symbol  
msoShapeFlowchartSort 80 Sort flowchart symbol  
msoShapeFlowchartExtract 81 Extract flowchart symbol  
msoShapeFlowchartMerge 82 Merge flowchart symbol  
msoShapeFlowchartStoredData 83 Stored data flowchart symbol  
msoShapeFlowchartDelay 84 Delay flowchart symbol  
msoShapeFlowchartSequentialAccessStorage 85 Sequential access storage flowchart symbol  
msoShapeFlowchartMagneticDisk 86 Magnetic disk flowchart symbol  
msoShapeFlowchartDirectAccessStorage 87 Direct access storage flowchart symbol  
msoShapeFlowchartDisplay 88 Display flowchart symbol  
msoShapeExplosion1 89 Explosion  
msoShapeExplosion2 90 Explosion  
msoShape4pointStar 91 4-point star  
msoShape5pointStar 92 5-point star  
msoShape8pointStar 93 8-point star  
msoShape16pointStar 94 16-point star  
msoShape24pointStar 95 24-point star  
msoShape32pointStar 96 32-point star  
msoShapeUpRibbon 97 Ribbon banner with center area above ribbon ends  
msoShapeDownRibbon 98 Ribbon banner with center area below ribbon ends  
msoShapeCurvedUpRibbon 99 Ribbon banner that curves up  
msoShapeCurvedDownRibbon 100 Ribbon banner that curves down  
msoShapeVerticalScroll 101 Vertical scroll  
msoShapeHorizontalScroll 102 Horizontal scroll  
msoShapeWave 103 Wave  
msoShapeDoubleWave 104 Double wave  
msoShapeRectangularCallout 105 Rectangular callout  
msoShapeRoundedRectangularCallout 106 Rounded rectangle-shaped callout  
msoShapeOvalCallout 107 Oval-shaped callout  
msoShapeCloudCallout 108 Cloud callout  
msoShapeLineCallout1 109 Callout with border and horizontal callout line  
msoShapeLineCallout2 110 Callout with diagonal straight line  
msoShapeLineCallout3 111 Callout with angled line  
msoShapeLineCallout4 112 Callout with callout line segments forming a U-shape  
msoShapeLineCallout1AccentBar 113 Callout with horizontal accent bar  
msoShapeLineCallout2AccentBar 114 Callout with diagonal callout line and accent bar  
msoShapeLineCallout3AccentBar 115 Callout with angled callout line and accent bar  
msoShapeLineCallout4AccentBar 116 Callout with accent bar and callout line segments forming a U-shape  
msoShapeLineCallout1NoBorder 117 Callout with horizontal line  
msoShapeLineCallout2NoBorder 118 Callout with no border and diagonal callout line  
msoShapeLineCallout3NoBorder 119 Callout with no border and angled callout line  
msoShapeLineCallout4NoBorder 120 Callout with no border and callout line segments forming a U-shape  
msoShapeLineCallout1BorderandAccentBar 121 Callout with border and horizontal accent bar  
msoShapeLineCallout2BorderandAccentBar 122 Callout with border, diagonal straight line, and accent bar  
msoShapeLineCallout3BorderandAccentBar 123 Callout with border, angled callout line, and accent bar  
msoShapeLineCallout4BorderandAccentBar 124 Callout with border, accent bar, and callout line segments forming a U-shape  
msoShapeActionButtonCustom 125 Button with no default picture or text. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonHome 126 Home button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonHelp 127 Help button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonInformation 128 Information button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonBackorPrevious 129 Back or Previous button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonForwardorNext 130 Forward or Next button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonBeginning 131 Beginning button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonEnd 132 End button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonReturn 133 Return button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonDocument 134 Document button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonSound 135 Sound button. Supports mouse-click and mouse-over actions.  
msoShapeActionButtonMovie 136 Movie button. Supports mouse-click and mouse-over actions.  
msoShapeBalloon 137 Balloon  
msoShapeNotPrimitive 138 Not supported  
msoShapeFlowchartOfflineStorage 139 Offline storage flowchart symbol  
msoShapeLeftRightRibbon 140 Ribbon with an arrow at both ends  
msoShapeDiagonalStripe 141 Rectangle with two triangles-shapes removed; a diagonal stripe  
msoShapePie 142 Circle ('pie') with a portion missing  
msoShapeNonIsoscelesTrapezoid 143 Trapezoid with asymmetrical non-parallel sides  
msoShapeDecagon 144 Decagon  
msoShapeHeptagon 145 Heptagon  
msoShapeDodecagon 146 Dodecagon  
msoShape6pointStar 147 6-point star  
msoShape7pointStar 148 7-point star  
msoShape10pointStar 149 10-point star  
msoShape12pointStar 150 12-point star  
msoShapeRound1Rectangle 151 Rectangle with one rounded corner  
msoShapeRound2SameRectangle 152 Rectangle with two-rounded corners that share a side  
msoShapeSnipRoundRectangle 154 Rectangle with one snipped corner and one rounded corner  
msoShapeSnip1Rectangle 155 Rectangle with one snipped corner  
msoShapeSnip2SameRectangle 156 Rectangle with two snipped corners that share a side  
msoShapeRound2DiagRectangle 157 Rectangle with two rounded corners, diagonally-opposed  
msoShapeSnip2DiagRectangle 157 Rectangle with two snipped corners, diagonally-opposed  
msoShapeFrame 158 Rectangular picture frame  
msoShapeHalfFrame 159 Half of a rectangular picture frame  
msoShapeTear 160 Water droplet  
msoShapeChord 161 Circle with a line connecting two points on the perimeter through the interior of the circle; a circle with a chord  
msoShapeCorner 162 Rectangle with rectangular-shaped hole.  
msoShapeMathPlus 163 Addition symbol +  
msoShapeMathMinus 164 Subtraction symbol -  
msoShapeMathMultiply 165 Multiplication symbol x  
msoShapeMathDivide 166 Division symbol ÷  
msoShapeMathEqual 167 Equivalence symbol =  
msoShapeMathNotEqual 168 Non-equivalence symbol   
msoShapeCornerTabs 169 Four right triangles aligning along a rectangular path; four 'snipped' corners.  
msoShapeSquareTabs 170 Four small squares that define a rectangular shape  
msoShapePlaqueTabs 171 Four quarter-circles defining a rectangular shape  
msoShapeGear6 172 Gear with six teeth  
msoShapeGear9 173 Gear with nine teeth  
msoShapeFunnel 174 Funnel  
msoShapePieWedge 175 Quarter of a circular shape  
msoShapeLeftCircularArrow 176 Circular arrow pointing counter-clockwise  
msoShapeLeftRightCircularArrow 177 Circular arrow pointing clockwise and counter-clockwise; a curved arrow with points at both ends  
msoShapeSwooshArrow 178 Curved arrow  
msoShapeCloud 179 Cloud shape  
msoShapeChartX 180 Square divided into four parts along diagonal lines  
msoShapeChartStar 181 Square divided into six parts along vertical and diagonal lines  
msoShapeChartPlus 182 Square divided vertically and horizontally into four quarters  
msoShapeLineInverse 183 Line inverse  

리스트 출처 : https://docs.microsoft.com/en-us/office/vba/api/office.msoautoshapetype

 

MsoAutoShapeType enumeration (Office)

MsoAutoShapeType enumeration (Office) In this article --> Specifies the shape type for an AutoShape object. Name Value Description msoShape10pointStar 149 10-point star msoShape12pointStar 150 12-point star msoShape16pointStar 94 16-point star msoShape24po

docs.microsoft.com

이상입니다!

댓글