Setting Minimum and Max Scale in VBA

gmatriix

Registered User.
Local time
Yesterday, 23:14
Joined
Mar 19, 2007
Messages
365
Hello All,

I have a chart that I am setting Min and Max Scales in the Chart. This works perfectly in 2003 but in 2010 I get "the caller is dispatching an asynchronous call and cannot make an outgoing call on behalf of this call"

This is on the updated event of the chart. It works fine in 2003. It is failing on the following code.

Code:
Me.Graph194.axes(2).MinimumScale = Me.LL -0.006
Me.Graph194.axes(2).MaximumScale = Me.LL -0.006

Do this have to written different in 2010? I tried this portion of the code on other event and I get 1004 runtime error???

Any Ideas?

Thanks
 
So what is Me.LL? You seem to set the minimum and maximum scales the same value? If Me.LL is 0.006 then Minimum and Maximum scales will both 0??
 
Sorry,

Me.LL is the lower limit and it is supposed to say "UL" for upper limit so it should look like this
Code:
Me.Graph194.axes(2).MinimumScale = Me.LL - 0.0008
Me.Graph194.axes(2).MaximumScale = Me.UL + 0.0006

Here is the whole code that works great in 2003...I know it maybe alittle long winded but it works.....just not in 2010

Code:
Private Sub Graph194_Updated(Code As Integer)



Dim GColor As Variant
Dim YColor As Variant
Dim RColor As Variant

    Dim BColor10 As Variant
    Dim BColor9 As Variant
    Dim BColor8 As Variant
    Dim BColor7 As Variant
    Dim BColor6 As Variant
    Dim BColor5 As Variant
    Dim BColor4 As Variant
    Dim BColor3 As Variant
    Dim BColor2 As Variant
    Dim BColor1 As Variant

Dim Bar1 As Variant
Dim Bar2 As Variant
Dim Bar3 As Variant
Dim Bar4 As Variant
Dim Bar5 As Variant
Dim Bar6 As Variant
Dim Bar7 As Variant
Dim Bar8 As Variant
Dim Bar9 As Variant
Dim Bar10 As Variant
Dim Bar11 As Variant
Dim Bar12 As Variant
Dim Bar13 As Variant
Dim Bar14 As Variant
Dim Bar15 As Variant


Bar1 = DLookup("ColorCode", "Keyview", "KeyCounter = 1")
Bar2 = DLookup("ColorCode", "Keyview", "KeyCounter = 2")
Bar3 = DLookup("ColorCode", "Keyview", "KeyCounter = 3")
Bar4 = DLookup("ColorCode", "Keyview", "KeyCounter = 4")
Bar5 = DLookup("ColorCode", "Keyview", "KeyCounter = 5")
Bar6 = DLookup("ColorCode", "Keyview", "KeyCounter = 6")
Bar7 = DLookup("ColorCode", "Keyview", "KeyCounter = 7")
Bar8 = DLookup("ColorCode", "Keyview", "KeyCounter = 8")
Bar9 = DLookup("ColorCode", "Keyview", "KeyCounter = 9")
Bar10 = DLookup("ColorCode", "Keyview", "KeyCounter = 10")
Bar11 = DLookup("ColorCode", "Keyview", "KeyCounter = 11")
Bar12 = DLookup("ColorCode", "Keyview", "KeyCounter = 12")
Bar13 = DLookup("ColorCode", "Keyview", "KeyCounter = 13")
Bar14 = DLookup("ColorCode", "Keyview", "KeyCounter = 14")
Bar15 = DLookup("ColorCode", "Keyview", "KeyCounter = 15")

GColor = RGB(0, 255, 0)
YColor = RGB(255, 153, 51)
RColor = RGB(255, 0, 0)

On Error GoTo QuitGraph

Me.Graph194.axes(2).MinimumScale = Me.LL - 0.0008
Me.Graph194.axes(2).MaximumScale = Me.UL + 0.0006

    If Bar15 = 1 Then Me.Graph194.SeriesCollection(1).Points(15).Interior.Color = GColor
    If Bar15 = 2 Then Me.Graph194.SeriesCollection(1).Points(15).Interior.Color = YColor
    If Bar15 = 3 Then Me.Graph194.SeriesCollection(1).Points(15).Interior.Color = RColor

If Bar14 = 1 Then Me.Graph194.SeriesCollection(1).Points(14).Interior.Color = GColor
If Bar14 = 2 Then Me.Graph194.SeriesCollection(1).Points(14).Interior.Color = YColor
If Bar14 = 3 Then Me.Graph194.SeriesCollection(1).Points(14).Interior.Color = RColor

    If Bar13 = 1 Then Me.Graph194.SeriesCollection(1).Points(13).Interior.Color = GColor
    If Bar13 = 2 Then Me.Graph194.SeriesCollection(1).Points(13).Interior.Color = YColor
    If Bar13 = 3 Then Me.Graph194.SeriesCollection(1).Points(13).Interior.Color = RColor

If Bar12 = 1 Then Me.Graph194.SeriesCollection(1).Points(12).Interior.Color = GColor
If Bar12 = 2 Then Me.Graph194.SeriesCollection(1).Points(12).Interior.Color = YColor
If Bar12 = 3 Then Me.Graph194.SeriesCollection(1).Points(12).Interior.Color = RColor

    If Bar11 = 1 Then Me.Graph194.SeriesCollection(1).Points(11).Interior.Color = GColor
    If Bar11 = 2 Then Me.Graph194.SeriesCollection(1).Points(11).Interior.Color = YColor
    If Bar11 = 3 Then Me.Graph194.SeriesCollection(1).Points(11).Interior.Color = RColor

If Bar10 = 1 Then Me.Graph194.SeriesCollection(1).Points(10).Interior.Color = GColor
If Bar10 = 2 Then Me.Graph194.SeriesCollection(1).Points(10).Interior.Color = YColor
If Bar10 = 3 Then Me.Graph194.SeriesCollection(1).Points(10).Interior.Color = RColor

    If Bar9 = 1 Then Me.Graph194.SeriesCollection(1).Points(9).Interior.Color = GColor
    If Bar9 = 2 Then Me.Graph194.SeriesCollection(1).Points(9).Interior.Color = YColor
    If Bar9 = 3 Then Me.Graph194.SeriesCollection(1).Points(9).Interior.Color = RColor
    
If Bar8 = 1 Then Me.Graph194.SeriesCollection(1).Points(8).Interior.Color = GColor
If Bar8 = 2 Then Me.Graph194.SeriesCollection(1).Points(8).Interior.Color = YColor
If Bar8 = 3 Then Me.Graph194.SeriesCollection(1).Points(8).Interior.Color = RColor

    If Bar7 = 1 Then Me.Graph194.SeriesCollection(1).Points(7).Interior.Color = GColor
    If Bar7 = 2 Then Me.Graph194.SeriesCollection(1).Points(7).Interior.Color = YColor
    If Bar7 = 3 Then Me.Graph194.SeriesCollection(1).Points(7).Interior.Color = RColor
    
If Bar6 = 1 Then Me.Graph194.SeriesCollection(1).Points(6).Interior.Color = GColor
If Bar6 = 2 Then Me.Graph194.SeriesCollection(1).Points(6).Interior.Color = YColor
If Bar6 = 3 Then Me.Graph194.SeriesCollection(1).Points(6).Interior.Color = RColor

    If Bar5 = 1 Then Me.Graph194.SeriesCollection(1).Points(5).Interior.Color = GColor
    If Bar5 = 2 Then Me.Graph194.SeriesCollection(1).Points(5).Interior.Color = YColor
    If Bar5 = 3 Then Me.Graph194.SeriesCollection(1).Points(5).Interior.Color = RColor
    
If Bar4 = 1 Then Me.Graph194.SeriesCollection(1).Points(4).Interior.Color = GColor
If Bar4 = 2 Then Me.Graph194.SeriesCollection(1).Points(4).Interior.Color = YColor
If Bar4 = 3 Then Me.Graph194.SeriesCollection(1).Points(4).Interior.Color = RColor

    If Bar3 = 1 Then Me.Graph194.SeriesCollection(1).Points(3).Interior.Color = GColor
    If Bar3 = 2 Then Me.Graph194.SeriesCollection(1).Points(3).Interior.Color = YColor
    If Bar3 = 3 Then Me.Graph194.SeriesCollection(1).Points(3).Interior.Color = RColor
    
If Bar2 = 1 Then Me.Graph194.SeriesCollection(1).Points(2).Interior.Color = GColor
If Bar2 = 2 Then Me.Graph194.SeriesCollection(1).Points(2).Interior.Color = YColor
If Bar2 = 3 Then Me.Graph194.SeriesCollection(1).Points(2).Interior.Color = RColor

    If Bar1 = 1 Then Me.Graph194.SeriesCollection(1).Points(1).Interior.Color = GColor
    If Bar1 = 2 Then Me.Graph194.SeriesCollection(1).Points(1).Interior.Color = YColor
    If Bar1 = 3 Then Me.Graph194.SeriesCollection(1).Points(1).Interior.Color = RColor
    
QuitGraph:
End Sub

....any ideas?
 
Last edited:
I have never used Graphs in detail like this before, so I have to say 'Sorry buddy'.. :(

Someone would be coming along to help you out soon.. In the mean time, check if the values of LL and UL are offending the result..
 
No Prob.....I know this is a unusual question.....it works great in 2003...it changes that bar color based off tolerances. My boss want to use it in 2010 runtime....so I am struggling trying to get the code to work in 2010....urrrrrg!

Anyone else care to take a crack at it?
 

Users who are viewing this thread

Back
Top Bottom