Formatting and editing shape

dturgel

Board Regular
Joined
Aug 6, 2015
Messages
58
Hi, I recorded a macro to format a rectangle as green outline and then put the letter 'B' and make that 'B' bold. The recording yielded the following code. When I went to run that same macro it got stuck on this line: With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 1).Font.Fill with the following error: vba error the index into the specific collection is out of bounds. I looked this error up and could not find a good solution for my specific problem - anyone have any ideas and while we're at it any way to make it more concise (in particular to get rid of .Select)? Thanks!

ActiveSheet.Shapes.Range(Array("Rectangle 1")).Select
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 102, 0)
.Transparency = 0
End With
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 1).Font.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 102, 0)
.Transparency = 0
.Solid
End With
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "B"
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 1). _
ParagraphFormat
.FirstLineIndent = 0
.Alignment = msoAlignCenter
End With
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 1).Font
.Bold = msoTrue
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 102, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Name = "+mn-lt"
End With
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top