ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem setting font size (https://www.excelbanter.com/excel-programming/324456-problem-setting-font-size.html)

Edward Ulle

Problem setting font size
 
How do you set the font size for the following?

Set sShape = worksheet.AddShape(msoShapeRectangle, left, top, width,
height)
With sShape
.Fill.Transparency = 1#
.Line.Transparency = 1#
With .TextFrame
.Characters.Text = label
.HorizontalAlignment = xlHAlignCenter
.VerticalAlignment = xlVAlignCenter
End With
End With

Adding .Characters.Font.Size = 6 causes an error and using .AddLabel I
can set font size but can not center align the text.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Markus Scheible[_2_]

Problem setting font size
 
Good Morning Edward,


Set sShape = worksheet.AddShape(msoShapeRectangle, left,

top, width,
height)
With sShape
.Fill.Transparency = 1#
.Line.Transparency = 1#
With .TextFrame
.Characters.Text = label
.HorizontalAlignment = xlHAlignCenter
.VerticalAlignment = xlVAlignCenter
End With
End With

Adding .Characters.Font.Size = 6 causes an error and

using .AddLabel I
can set font size but can not center align the text.


I think the error is caused by your with command...
because .TextFrame.Characters.Font.Size won't be the right
address.

Try

Shapes.Characters.Font.Size = 25

Best

Markus




Edward Ulle

Problem setting font size
 
Markus

Through much trial and error. Lots of error. I finally got it to work
by including the following cText object.

Dim sShape As Shape
Dim cText As Characters ' Added

Set sShape = worksheet.AddShape(msoShapeRectangle, left,
top, width, height)
With sShape
.Fill.Transparency = 1#
.Line.Transparency = 1#
With .TextFrame
.Characters.Text = label
.HorizontalAlignment = xlHAlignCenter
.VerticalAlignment = xlVAlignCenter
End With
End With

Set cText = sShape.TextFrame.Characters ' Added
cText.Font.Size = 6 ' Added

Thanks for your suggestion.

Ed

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 07:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com