-
Notifications
You must be signed in to change notification settings - Fork 11
/
Excel VBA - Various Shapes.vb
58 lines (43 loc) · 1.43 KB
/
Excel VBA - Various Shapes.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Sub Adding_Text_toShape()
'Set element to put in shape'
Dim element As String
element = ""
'Select shape'
'ActiveSheet.Shapes.Range(Array("Name of the shape")).Select
'Place element in shape'
'--> Chr(13) creates new line'
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Fact" & Chr(13) & element
End Sub
Sub Moving_aShape()
'Example of moving shape to left'
Selection.ShapeRange.IncrementLeft -372
'Example of moving shape to right'
Selection.ShapeRange.IncrementTop -39.75
End Sub
Sub Adding_aChart()
'Selecting chart to include'
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
'Choose source range'
ActiveChart.SetSourceData Source:=Range("Stages!$B$8:$G$32")
'Move chart'
ActiveSheet.Shapes("Chart 4").IncrementLeft -210
'Resize chart'
ActiveSheet.Shapes("Chart 4").ScaleWidth 1.1604166667, msoFalse, msoScaleFromTopLeft
End Sub
Sub InsertTextBox()
'Insert text box'
ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 156.75, 148.5, 223.5, 82.5).Select
'Insert text in box'
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = ""
End Sub
Sub Widden_Column()
Columns("F:F").ColumnWidth = 15.88
End Sub
Sub InsertPicture()
'Inserting a picture'
ActiveSheet.Pictures.Insert("C:\Users\Zadig\Pictures\9kfvQD.jpg").Select
'Change picture name'
Selection.ShapeRange.Name = "Give a name"
'Delete picture'
Selection.Delete
End Sub