ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting ThemeFont and ThemeColor (https://www.excelbanter.com/excel-programming/422888-setting-themefont-themecolor.html)

Jan Kuera

Setting ThemeFont and ThemeColor
 
Hello...

Dim sh As Shape

Set sh = Sheet1.Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame2.TextRange.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.ThemeFont = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.ThemeColor = xlThemeColorLight2

both last two rows returns
1004 Application-defined or object-defined error.

Anybody has an idea what is wrong?

Thanks!
Jan

Conrad S

Setting ThemeFont and ThemeColor
 
Try this:

Sub test()
Dim sh As Shape

Set sh = Sheets(1).Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame.Characters.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.Name = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.Color = xlThemeColorLight2

End Sub
--
Conrad S
#Don''t forget to click "Yes" if this post was helpful!#


"Jan Kučera" wrote:

Hello...

Dim sh As Shape

Set sh = Sheet1.Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame2.TextRange.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.ThemeFont = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.ThemeColor = xlThemeColorLight2

both last two rows returns
1004 Application-defined or object-defined error.

Anybody has an idea what is wrong?

Thanks!
Jan


Jan Kučera

Setting ThemeFont and ThemeColor
 
Thanks Conrad for try, but
Error 1004, "Unable to set the Name property of the Font class" this time.

Jan


"Conrad S" wrote in message
...
Try this:

Sub test()
Dim sh As Shape

Set sh = Sheets(1).Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame.Characters.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.Name = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.Color = xlThemeColorLight2

End Sub
--
Conrad S
#Don''t forget to click "Yes" if this post was helpful!#


"Jan Kučera" wrote:

Hello...

Dim sh As Shape

Set sh = Sheet1.Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame2.TextRange.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.ThemeFont = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.ThemeColor = xlThemeColorLight2

both last two rows returns
1004 Application-defined or object-defined error.

Anybody has an idea what is wrong?

Thanks!
Jan


Jan Kučera

Setting ThemeFont and ThemeColor
 
Gotcha!

it is .Font.Fill.ForeColor.SchemeColor and .FontName = xlThemeFontMajor of
TextFrame2.

Thanks for hint!

Jan

"Jan Kučera" wrote in message
...
Thanks Conrad for try, but
Error 1004, "Unable to set the Name property of the Font class" this time.

Jan


"Conrad S" wrote in message
...
Try this:

Sub test()
Dim sh As Shape

Set sh = Sheets(1).Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame.Characters.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.Name = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.Color = xlThemeColorLight2

End Sub
--
Conrad S
#Don''t forget to click "Yes" if this post was helpful!#


"Jan Kučera" wrote:

Hello...

Dim sh As Shape

Set sh = Sheet1.Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame2.TextRange.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.ThemeFont = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.ThemeColor = xlThemeColorLight2

both last two rows returns
1004 Application-defined or object-defined error.

Anybody has an idea what is wrong?

Thanks!
Jan


Jan Kučera

Setting ThemeFont and ThemeColor
 
:-( unfortunately, although it does not through an errors,
..Font.Name = xlThemeFontMajor
just sets the font name to "1" and neither
..Font.Fill.ForeColor.SchemeColor = xlThemeColorLight2
nor
..Font.Fill.ForeColor.ObjectThemeColor = xlThemeColorLight2

match the scheme colors..
why is this not documented? How should this be used?

Jan

"Jan Kučera" wrote in message
...
Gotcha!

it is .Font.Fill.ForeColor.SchemeColor and .Font.Name = xlThemeFontMajor
of TextFrame2.

Thanks for hint!

Jan

"Jan Kučera" wrote in message
...
Thanks Conrad for try, but
Error 1004, "Unable to set the Name property of the Font class" this
time.

Jan


"Conrad S" wrote in message
...
Try this:

Sub test()
Dim sh As Shape

Set sh = Sheets(1).Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame.Characters.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.Name = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.Color = xlThemeColorLight2

End Sub
--
Conrad S
#Don''t forget to click "Yes" if this post was helpful!#


"Jan Kučera" wrote:

Hello...

Dim sh As Shape

Set sh = Sheet1.Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame2.TextRange.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.ThemeFont = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.ThemeColor = xlThemeColorLight2

both last two rows returns
1004 Application-defined or object-defined error.

Anybody has an idea what is wrong?

Thanks!
Jan


Jan Kučera

Setting ThemeFont and ThemeColor
 
Okay, the correct use with color is to set
ObjectThemeColor to any of the msoThemeColor constants instead of
xlThemeColor.

Now only the theme font issue remains...

Jan

"Jan Kučera" wrote in message
...
:-( unfortunately, although it does not through an errors,
.Font.Name = xlThemeFontMajor
just sets the font name to "1" and neither
.Font.Fill.ForeColor.SchemeColor = xlThemeColorLight2
nor
.Font.Fill.ForeColor.ObjectThemeColor = xlThemeColorLight2

match the scheme colors..
why is this not documented? How should this be used?

Jan

"Jan Kučera" wrote in message
...
Gotcha!

it is .Font.Fill.ForeColor.SchemeColor and .Font.Name = xlThemeFontMajor
of TextFrame2.

Thanks for hint!

Jan

"Jan Kučera" wrote in message
...
Thanks Conrad for try, but
Error 1004, "Unable to set the Name property of the Font class" this
time.

Jan


"Conrad S" wrote in message
...
Try this:

Sub test()
Dim sh As Shape

Set sh = Sheets(1).Shapes.AddShape(msoShapeRectangle, 0, 0, 100,
100)
sh.TextFrame.Characters.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.Name = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.Color = xlThemeColorLight2

End Sub
--
Conrad S
#Don''t forget to click "Yes" if this post was helpful!#


"Jan Kučera" wrote:

Hello...

Dim sh As Shape

Set sh = Sheet1.Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 100)
sh.TextFrame2.TextRange.Text = "Hello world!"

sh.TextFrame.Characters(0, 12).Font.ThemeFont = xlThemeFontMajor
sh.TextFrame.Characters(0, 12).Font.ThemeColor = xlThemeColorLight2

both last two rows returns
1004 Application-defined or object-defined error.

Anybody has an idea what is wrong?

Thanks!
Jan



All times are GMT +1. The time now is 04:25 AM.

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