Sub setup()
Call createButton("Add", "E2", "addNewKeyTopic")
Call createButton("Delete", "E5", "deleteKeyTopic")
End Sub
Sub createButton(sLabel As String, sPos As String, sFunctionName As String)
' sPos is the location for the button
Sheets("Input").Shapes.AddShape(msoShapeRectangle, _
Range(sPos).Left, _
Range(sPos).Top, _
Range(sPos).Width * 2, _
Range(sPos).Height).Select
'Sheets("Input").Shapes.AddShape(msoShapeRoundedRectangle, _
'Range(sPos).Left, _
'Range(sPos).Top, _
'Range(sPos).Width * 2, _
'Range(sPos).Height).Select
Selection.ShapeRange(1).TextFrame.Characters.Text = sLabel
Selection.ShapeRange(1).TextFrame.Characters.Font.Name = "Arial" ' Change the font name
Selection.ShapeRange(1).TextFrame.Characters.Font.Size = 12 ' Change the font size
Selection.ShapeRange(1).TextFrame.Characters.Font.Bold = True
Selection.ShapeRange(1).TextFrame.Characters.Font.Color = RGB(0, 120, 156) 'Change font color
Selection.ShapeRange(1).Fill.ForeColor.RGB = RGB(255, 153, 0) 'Change the background color of the Shape
Selection.ShapeRange(1).Line.ForeColor.RGB = RGB(0, 120, 156) 'Change the border line color of the Shape
Selection.ShapeRange(1).Line.Weight = 1.5 ' Set Line weight
Selection.ShapeRange(1).Line.Style = msoLineSingle
Selection.ShapeRange(1).TextFrame.HorizontalAlignment = xlCenter ' Align the text
Selection.ShapeRange(1).TextFrame.VerticalAlignment = xlTop ' Align the text vertically
Selection.ShapeRange(1).OnAction = "'" & sFunctionName & "'"
End Sub
No comments:
Post a Comment