Results 1 to 5 of 5
  1. #1
    mitch_pearce79 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2012
    Location
    Perth
    Posts
    15

    Manipulating Excel Chart using late binding (Custom Error Bars)

    Hi All,

    I have an excel spreadsheet resulting from code that I put together for a Bootstrap analysis of an environmental risk assessment.

    The sheet ("Bootstrap") ends up with a table as follows:

    Rank Site 2SD Average Score
    1 a 48 706
    2 b 22 282
    3 c 22 317
    4 d 19 272
    5 e 19 221
    6 f 9 159
    7 g 8 115
    8 h 10 122

    Where '2SD' is 2 x stdev (95% confidence) and 'Average Score' is the average site/sensitivity score over 1000000 random samples

    Now I need to make a clustered column graph in excel showing the average for each site (a-h), and add Error Bars to the value of +2SD/-2SD (range "Bootstrap!$C$2:$C$9")

    In excel2010 my code (below) gets hung up at the last line (Type:=xlCustom). It worked fine when I select standard error just to test it, but I want it to plot error bars for the range "Bootstrap!$C$2:$C$9"
    In excel2007 my code (below) gets hung up at the 'delete' line.

    Dim xl As Object
    Set xl = CreateObject("Excel.Application")



    xl.charts.Add
    xl.charts("Chart1").Name = "Bootstrap Graph"
    xl.charts("Bootstrap Graph").Activate
    xl.ActiveChart.FullSeriesCollection(1).Delete
    xl.ActiveChart.FullSeriesCollection(1).Select
    xl.ActiveChart.FullSeriesCollection(1).HasErrorBar s = True
    xl.ActiveChart.FullSeriesCollection(1).ErrorBars.S elect
    'xl.ActiveChart.SetElement (msoElementErrorBarStandardError)
    xl.ActiveChart.FullSeriesCollection(1).ErrorBar Direction:=xlY, Include:=xlBoth, Type:=xlCustom, Amount:="10" 'xl.Range("Bootstrap!$C$2:$C$9")

    I've searched and searched and not been able to find a solution... at least not using late binding anyway, which is my preference.

    Any ideas? Should I be setting workbooks, worksheets, chart objects and charts?

    Regards,

    Mitch

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    If nobody answers this you might try an excel forum, I personally don't do much of anything in excel so I am of no use on this question.

  3. #3
    mitch_pearce79 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2012
    Location
    Perth
    Posts
    15
    Cheers. I put it up here because I'm driving it all from access 2010. Most of the code above resulted from recording an excel macro and putting a "xl." in front... and most of it works. Since I recorded the macro from excel I'm assuming is should work IN excel, and that it must be a communication issue between access and excel? Fingers crossed someone has had this issue before and managed to resolve it

  4. #4
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    I doubt that using late binding vs early binding is the issue here. The only way early binding can help I think is it would identify if the properties/methods you are using exist in the object library. With early binding, you will get compilation errors for invalid properties/methods, but with late binding, the error happens at runtime.

  5. #5
    Jon Peltier is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    1
    The code isn't terribly efficient, but it looks like it ought to work. The issue isn't early vs. late binding but rather the use of new properties in an older version of Excel.

    FullSeriesCollection wasn't introduced until Excel 2013. Use SeriesCollection instead.

    Here is I would code this:

    Code:
    With xl.Charts.Add
        .Name = "Bootstrap Graph"
        .SeriesCollection(1).Delete
        With .SeriesCollection(1)
            .ErrorBar Direction:=xlY, Include:=xlBoth, Type:=xlCustom, Amount:=xl.Range("Bootstrap!$C$2:$C$9"), MinusValues:=xl.Range("Bootstrap!$C$2:$C$9")
        End With
    End With
    For Excel questions, try the Mr Excel forum.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. send outlook email with late binding
    By markjkubicki in forum Programming
    Replies: 3
    Last Post: 01-24-2014, 09:39 AM
  2. How do I achieve late binding on a Chart?
    By RocketMonkey in forum Forms
    Replies: 1
    Last Post: 02-12-2013, 02:11 PM
  3. Add Error bars to column chart
    By kzimm14 in forum Reports
    Replies: 7
    Last Post: 02-02-2012, 01:09 PM
  4. Who to label all the bars of the chart at a time?
    By jamal numan in forum Access
    Replies: 4
    Last Post: 01-29-2012, 02:18 PM
  5. Replies: 0
    Last Post: 06-02-2011, 04:19 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums