A couple of errors. Copy/paste & run the code below. Amend as necessary.
1. You need to keep an eye on the heirarchy of object properties. For example you will see how I have repositioned '.Fill' in your code.
2. You are not showing an initialisation of the Sheetname variable. Your code at present will show nothing for this - with no error message.
3. You have defined ForeColor and BackColor the same - so no gradient effect. Need to set the font colour a contrasting colour too.
4. '.Name = Sheetname' will work (assuming you have defined 'Sheetname' as in 2) ... but only once.
If you want to make another shape you will need to give it another name - or get an error message.
See in my code how I have used the code for a single Trapezoid in a subroutine to achieve this. See how much easier it is to re-format the shape set as necessary.
A couple of pointers regarding messages in the forum. If we can read and understand your code it is more likely you will get an answer. The more you can help us, the more we can help you.
1. Please format your code correctly in the code module, and add comments to show what it is supposed to do.
The more advanced you get,with bigger projects, the more you will be doing this for yourself anyway. I can often go back to code I wrote months ago and change it in a couple of minutes.
2. Copy/paste the code into your message and select it and click the [#] 'Code' button above the message. If the button is not there you will need to type in the HTML tags manually. [ code] at the beginning and [ /code] (without spaces) at the end. This ensures your formatting stays intact.
2. "doesn't seem to like .. " is not a good desciption of a problem. We need to know the line number the code stops at, and the error message. What do you want to happen ? What actually happens ? You did give a good message title.
Hope all this helps - and welcome to the forum.
Code:
'=============================================================================
'- Prepare the buttons (Rectangles) for the menus (THIS CODE ONLY DOES 1)
'=============================================================================
Sub test()
Dim ShapeObj As Object
Dim SheetName As String
'-------------------------------------------------------------------------
Sheets("MenuBoth").Range("A1").Select ' only works if the sheet is the Active one
SheetName = "Test"
'-------------------------------------------------------------------------
'(Across Page, Down Page, length, width)
Set ShapeObj = _
Sheets("MenuBoth").Shapes.AddShape(msoShapeRectangle, 10, 210, 170, 25)
'--------------------------------------------------------------------------
With ShapeObj
'----------------------------------------------------------------------
.Fill.ForeColor.RGB = RGB(0, 0, 255)
.Fill.BackColor.RGB = RGB(0, 0, 97)
.Fill.TwoColorGradient msoGradientHorizontal, 1
'---------------------------------------------------------------------
'- NAME THE RECTANGLE
.Name = SheetName
'---------------------------------------------------------------------
'- RUN A MACRO
' .OnAction = "Macro1"
'---------------------------------------------------------------------
With .TextFrame
.Characters.Text = SheetName
.Characters.Font.Size = 10
.Characters.Font.ColorIndex = 2
.HorizontalAlignment = xlHAlignCenter
.VerticalAlignment = xlVAlignCenter
End With
'--------------------------------------------------------------------
End With
End Sub
'=============================================================================