Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
KvnLynch
 
Posts: n/a
Default Problem with Chart Title Formatting

I have what I thought would be a very simple task. I want the first line of
a Chart title to be a large font size, while making the second line a smaller
font size.

I wrote the VBA code listed below. I thought all I would need to do is use
the Characters property to change each part of the title. I did so and
everything seemed to work OK until I decided to try and format the 2nd line
using italics.

By inserting the italics line (which is currently commented out), excel
chages the font size to the same size as the 1st line (20 in this case)

Does anybody see an obvious mistake? Could someon try pasting this code
into their VBE and try it out on a chart with/with out the italic line? For
purposes of this example, assume Line 1 reads "TEST", while line 2 reads "Why
does this not work". Your help would be much appreciated.

Thanks




Sub FormatChart1Title()
Set Cht = Charts(1)
Cht.Select
With Cht.ChartTitle
.AutoScaleFont = False
With .Characters(Start:=1, Length:=5).Font
.Name = "Franklin Gothic Book"
.Bold = True
.Size = 20
.Italic = False
End With

.AutoScaleFont = False

With .Characters(Start:=6, Length:=22).Font
.Name = "Franklin Gothic Book"
.Bold = True
.Size = 8
'.Italic = True
End With
End With
Cht.Select

End Sub
  #2   Report Post  
Jon Peltier
 
Posts: n/a
Default

Kevin -

Sometimes text objects cannot be reliably formatted character by character, if
you're doing too many different formats. But yours is pretty straightforward.

It's better to format the entire text object, then just format the part that's
different. I've amended your procedure below, and it worked just as I expected
(yours worked just as you'd described).

Sub FormatChart1Title()
Dim Cht As Chart

Set Cht = Charts(1)

With Cht.ChartTitle
.AutoScaleFont = False

' Format the entire title
With .Font
.Name = "Franklin Gothic Book"
.Bold = True
.Size = 20
End With

' Reformat just one part
With .Characters(Start:=6, Length:=22).Font
.Italic = True
.Size = 8
End With

End With

End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


KvnLynch wrote:

I have what I thought would be a very simple task. I want the first line of
a Chart title to be a large font size, while making the second line a smaller
font size.

I wrote the VBA code listed below. I thought all I would need to do is use
the Characters property to change each part of the title. I did so and
everything seemed to work OK until I decided to try and format the 2nd line
using italics.

By inserting the italics line (which is currently commented out), excel
chages the font size to the same size as the 1st line (20 in this case)

Does anybody see an obvious mistake? Could someon try pasting this code
into their VBE and try it out on a chart with/with out the italic line? For
purposes of this example, assume Line 1 reads "TEST", while line 2 reads "Why
does this not work". Your help would be much appreciated.

Thanks




Sub FormatChart1Title()
Set Cht = Charts(1)
Cht.Select
With Cht.ChartTitle
.AutoScaleFont = False
With .Characters(Start:=1, Length:=5).Font
.Name = "Franklin Gothic Book"
.Bold = True
.Size = 20
.Italic = False
End With

.AutoScaleFont = False

With .Characters(Start:=6, Length:=22).Font
.Name = "Franklin Gothic Book"
.Bold = True
.Size = 8
'.Italic = True
End With
End With
Cht.Select

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Relative Chart Title? Nick M Charts and Charting in Excel 6 June 22nd 05 09:24 PM
Strange Problem with Chart and Plot Visible Cells Option Marcus Leon Charts and Charting in Excel 1 January 7th 05 03:52 AM
how to cell reference a Chart title Rasoul Khoshravan Azar Charts and Charting in Excel 2 January 1st 05 05:00 PM
Problem with xlusrgal.xls file Alfred S C Lee Charts and Charting in Excel 2 December 29th 04 05:54 PM
Area Chart Formatting Question Avrilon Charts and Charting in Excel 3 December 2nd 04 09:14 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"