#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Chart font

Hi,

i have some 20 charts in a sheet along with the data. I want to change
the fonts of all the charts i.e. title, axis etc. i was able to do
this but some of my charts also have secondary axis and font for the
secondary is not changing.

How to achieve this. I used below code to achieve. Please tell where i
am wrong.

Sub Test()
Dim sht As Worksheet
Dim chtObject As ChartObject
Dim cht As Chart



For Each sht In Worksheets
For Each chtObject In sht.ChartObjects
Set cht = chtObject.Chart
''With cht.Axes(xlCategory)
' .TickLabels.Font.Size = 8
' .AxisTitle.Font.Size = 8
' End With
'On Error Resume Next
For Each a In cht.Axes
With cht.Axes(xlValue)
.TickLabels.Font.Size = 8
.AxisTitle.Font.Size = 8
End With

Next a
With cht.DataTable
.Font.Size = 8
End With
With cht.ChartTitle
.Font.Size = 8
End With
Next chtObject
End Sub

Thanks for the help in advance.

Navin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Chart font

Hi Navin,

This bit -

For Each a In cht.Axes
With cht.Axes(xlValue)
.TickLabels.Font.Size = 8
.AxisTitle.Font.Size = 8
End With


try -
For Each a In cht.Axes
a.TickLabels.Font.Size = 8
If a.HasTitle Then
a.AxisTitle.Font.Size = 8
End If
Next

also declare a, Dim a as Axis

You might still need an error handler. An axis might exist with all the
ticklabels properties but if these are not displayed it will fail, eg with
datalabels and some other scenarios.

FWIW can't use "For Each a In cht.Axes" in xl97, need to check if each axis
exists first.

Regards,
Peter T


"navin" wrote in message
ups.com...
Hi,

i have some 20 charts in a sheet along with the data. I want to change
the fonts of all the charts i.e. title, axis etc. i was able to do
this but some of my charts also have secondary axis and font for the
secondary is not changing.

How to achieve this. I used below code to achieve. Please tell where i
am wrong.

Sub Test()
Dim sht As Worksheet
Dim chtObject As ChartObject
Dim cht As Chart



For Each sht In Worksheets
For Each chtObject In sht.ChartObjects
Set cht = chtObject.Chart
''With cht.Axes(xlCategory)
' .TickLabels.Font.Size = 8
' .AxisTitle.Font.Size = 8
' End With
'On Error Resume Next
For Each a In cht.Axes
With cht.Axes(xlValue)
.TickLabels.Font.Size = 8
.AxisTitle.Font.Size = 8
End With

Next a
With cht.DataTable
.Font.Size = 8
End With
With cht.ChartTitle
.Font.Size = 8
End With
Next chtObject
End Sub

Thanks for the help in advance.

Navin



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
format chart textbox font Kim Jackson Charts and Charting in Excel 2 January 9th 09 09:24 PM
2007 Chart font fashionroadkill Charts and Charting in Excel 0 November 6th 08 12:01 AM
Font Size in Chart Title Bill[_30_] Excel Programming 1 July 14th 06 04:06 PM
symbol font in chart doesn't appear Khoshravan Charts and Charting in Excel 6 June 19th 06 02:01 PM
xl chart font sizing into PPT Brian Reilly, MS MVP Charts and Charting in Excel 1 January 12th 05 02:58 AM


All times are GMT +1. The time now is 03:14 PM.

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"