Dynamically changing a chart on a form

darbid

Registered User.
Local time
Today, 13:37
Joined
Jun 26, 2008
Messages
1,428
I have a chart on a form.
The chart is small but the user can click on it and make it bigger.

I currently have the x and y axis text size set to scale with the size of the graph.

When it is resized to large I do not like the text size as it makes the actual chart too small.(mainly because some of the lables are large in length)

Can I change the text size other than in design mode?

If not can I dynamically toggle the scale property of the x / y axis?

Thanks guys.
 
i think thinking you can do this with the graph object and it's subobjects in VBA, but i don't know how. only in Excel...so you may want to have a gander at the help menu for GRAPH."properties" in Visual Basic.
 
Yeh I was thinking that too, but when I was looking in the object browser I limited the search to Access/VBA as I thought that Excel stuff would only be available on a Excel Worksheet. I was wrong.

For me it is a little different how it works but for those wanting to do this you use the following (graph_ConPro is my graph name);

Code:
Me![graph_ConPro].Axes(2).TickLabels.AutoScaleFont = False

Me![graph_ConPro].Axes(1).TickLabels.AutoScaleFont = False
Basically after the "Me![graph_ConPro]" I have been able to use things under the Chart object from excel. Thus the above turns off the autoscale property of the fonts for the Y (2) axis and the X (1) axis.

Thanks Adam for giving me the push in the right direction.
 
I thought I had this all done and dusted. Then i tried it on another computer:mad:

This is the code to change the labels on a graph

Code:
Me![graph_licensepotential].SeriesCollection(1).DataLabels.Font.size = 9
works fine on my computer but will not another.

I learn this stuff by first recording a macro in the office application. On this other computer I did a font size change and got

Code:
ActiveChart.SeriesCollection(1).DataLabels.Select
    Selection.AutoScaleFont = True
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "Regular"
        .Size = 14
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .Background = xlAutomatic
    End With
But on this other computer i get

Unable to set the font size of the font class - 1004
Can anyone please help me with this?
 
arhh The code is perfect. It was something really simple.

There was no series collection there.

I need to error catch when there is no series collection.
 

Users who are viewing this thread

Back
Top Bottom