I am trying to create a menu with shapes that create itself on every page and fills in sheet names as shape text boxes.
I want to loop through an array of sheet names and an array of macro names and assign a macro for each shape textbox.
I have code to create the rectangle that defines the menu.
I would like to check if the menyShp exists and if yes then exit sub.
I am stuck on how to loop through the two arrays and using the on action property of the shape to assign the macro to the correct shape?
Code to add another shape with sheet name in it:
To offset the shapes so that they automatically get in the correct column. I want to have 3 or 4 columns with 5 or 6 sheet names in each.
I think that I need to offset the left and top properties!
All suggestions on how to proceed are welcome!
I want to loop through an array of sheet names and an array of macro names and assign a macro for each shape textbox.
Code:
Dim sheetNames As Variant
Dim macroNames() As Variant
sheetNames = Array("Sheet1", "Sheet2", "Sheet3")
macroNames2 = Array("Macro1","Macro2","Macro3")
I have code to create the rectangle that defines the menu.
Code:
Dim menyShp As Shape
Dim menyHeaderShp As Shape
Set menyShp = Sheet2.Shapes.AddShape(msoShapeRectangle, 193, 55, 864, 260)
With menyShp
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Line.ForeColor.RGB = RGB(255, 255, 255)
.Name = "menyShape"
'.OnAction = ""
End With
Set menyHeaderShp = Sheet2.Shapes.AddShape(msoShapeRectangle, 195, 108, 303, 50)
With menyHeaderShp
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Line.ForeColor.RGB = RGB(255, 255, 255)
.Name = "menyHeaderShp"
.OnAction = "test2"
End With
I would like to check if the menyShp exists and if yes then exit sub.
I am stuck on how to loop through the two arrays and using the on action property of the shape to assign the macro to the correct shape?
Code to add another shape with sheet name in it:
Code:
ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 463.5, 139.5, 160, 26.5).Select
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Line.Visible = msoFalse
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Sheet1"
End Sub
To offset the shapes so that they automatically get in the correct column. I want to have 3 or 4 columns with 5 or 6 sheet names in each.
Code:
Worksheet.Shapes.AddShape(AutoShapeType, Left, Top, Width, Height)
I think that I need to offset the left and top properties!
All suggestions on how to proceed are welcome!
Last edited: