I would like to add shapes and modify them from 2010 Access vba in an Excel worksheet.
The code I wrote based on Excel 'record macro' is:
StrSheetName = "Menu"
wkbModels.Sheets.Add(before:=wkbModels.Sheets("Models")).Name = StrSheetName
Set wksModelsMenu = wkbModels.Sheets(StrSheetName)
With wksModelsMenu
iLeft = 1
iTop = 1
iWidth = 125
iHeight = 200
.Shapes.AddPicture fDirectory & "logo.jpg", False, True, iLeft, iTop, iWidth, iHeight
iLeft = 240
iTop = 1
iWidth = 300
iHeight = 125
.Shapes.AddShape(msoShapeRoundedRectangle, iLeft, iTop, iWidth, iHeight).Select
.Shapes(1).Range.ShapeStyle = msoShapeStylePreset10
.Shapes(1).Range.TextFrame2.TextRange.Font.Bold = msoTrue
.Shapes(1).Range.TextFrame2.VerticalAnchor = msoAnchorMiddle
.Shapes(1).Range.TextFrame2.TextRange.Characters.Text = _
"TEST TEST TEST"
.Shapes(1).Range.TextFrame2.TextRange.Characters.ParagraphFormat.Alignment = msoAlignCenter
.Shapes(1).Range.TextFrame2.TextRange.Characters.Font.Bold = msoTrue
End With
On the ".Shapes(1).Range.ShapeStyle..." and following ".Shapes(1)." statements I receive an error "Object doesn't support this property or method". Removing the "(1)" gives a compile error.
The mso library is installed and the referenced items (i.e., msoShapeStylePreset10) have the proper values.
Any ideas on what I need to do?