+ Reply to Thread
Results 1 to 4 of 4

Default chart type crashes vba code upon .add??

Hybrid View

  1. #1
    Registered User
    Join Date
    01-10-2011
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    9

    Default chart type crashes vba code upon .add??

    I have VBA script that generates charts and works on everyones computer except for one person in our group. The code would crash at the ".add" in the snippet below with the error that I was using wrong parameters for the charttype.

    Turns out the way we fixed it was to make her default chart type in her excel settings to be "XYscatter". Although it is working I would like to avoid having to do manual changes to users computers. Why didnt' my code generate the correct type of plot explicity instead of choking on the parameters as iff I was attempting to create a bar chart?

    Thanks for any insights :-)
    With ActiveSheet.ChartObjects.Add _
            (Left:=chartLeft, Width:=chartWidth, Top:=chartTop, Height:=chartHeight)
             .Chart.SetSourceData Source:=ActiveSheet.Range("a1", "a1")
             .Chart.ChartType = xlXYScatterLines
             .Chart.Parent.Name = newsheetnameis
     End With

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Default chart type crashes vba code upon .add??

    Does this person have the same excel version, include service packs and updates, as the others?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    01-10-2011
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Default chart type crashes vba code upon .add??

    Yes, these are managed computers and everyone just got upgraded to office 2007 (haha just in time for 2010).


    Quote Originally Posted by Andy Pope View Post
    Does this person have the same excel version, include service packs and updates, as the others?

  4. #4
    Registered User
    Join Date
    01-10-2011
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Default chart type crashes vba code upon .add??

    Looks like I might need a plotby in there as well as a chart type?

    from http://vbautomation.110mb.com/VBA/charting.htm
    Column chart is the default chart type in Excel, and although you can leave out PlotBy:= xlColumns, it is not a good idea because the user may have set his default chart type to a line chart or pie chart, and it doesn’t serve your purpose. SizeWithWindow Property sets MyChart1 to be sized to its window.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1