Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.crashesgpfs,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Generation of graphs from a template sheet crashes with VBA

Hello,

I'm having troubles with creating some graphs with an Excel VBA Macro.

I would like to create about 35 graphs from a set of data stored in a unique
datasheet. As the set of data can change (length, numbers, etc ..) I created
a macro to generate the graph starting from a template graph.

The macro runs correctly a few times but after a variable number of graph
(from 5 to 15, it depends on the weather), it crashes with :
Run-Time Error '-2147417848 (80010108)' : Methode 'XValues' of object
'series' failed

If i go in debug mode and repeat the error, I get :
Run-Time Error '1004' Unable to set the XValues property of the Series
class.

After this error, excel has always a strange behavior (unable to select
cells), and it always finishes by an excel crash.

I've tried many many things but nothing works :
I'm running Office XP SP2 under Windows 2000. It doesn't work
neither on office 2000 nor office 97 (win95).
I read the Kb article Q210684 about copying sheets . None of the
workaround worked
Save and close the workbook after each graph <- not
working
Import the graph from a template file (sheets.add
type:=template.xlt) <- not working
The codename looks ok (chart1, chart2, chart3, etc .)

I can't create a user-defined style as this worksheet will be
spread on many computers. Even more, the user-defined style can't hold all
information I need (logos, textbox, graph size, ..)

Here is what I do ..

startR is a variable which holds the row number of the dataset's beginning
startC is a variable which holds the colomn number of the dataset's
beginning


For i = 1 To nperfgraph
Sheets("ModelePerf").Copy Befo=Sheets(1)
Set NewGraph = Sheets(1)
NewGraph.Name = "Perf Wet-Dry (" & i & ")"
NewGraph.Axes(1).MinimumScale = Sheets("Data").Cells(startR,
StartC - 2).Value
NewGraph.Axes(1).MaximumScale = Sheets("Data").Cells(startR +
nperfpts, StartC - 2).Value
For j = 1 To nperfcurve
DoEvents
Call BuildSerie(NewGraph, startR, nperfpts, StartC - 2, StartC +
(j + ((i - 1) * nperfcurve)) - 1)
Next j
NewGraph.SeriesCollection(1).Delete
Set NewGraph = Nothing
DoEvents
Next i


Sub BuildSerie(NewGraph, Row, Npts, AxeXC, StartC)

Dim Line As Variant

Data = "=Data!"
Set serie = NewGraph.SeriesCollection.NewSeries
x = Data & "r" & Row & "c" & AxeXC & ":r" & Row + Npts & "c" & AxeXC
Valeur = Data & "r" & Row & "c" & StartC & ":r" & Row + Npts & "c" & StartC
nom = Data & "r" & Row - 2 & "c" & StartC
serie.XValues = x <--------------------- Macro crashes here.
serie.Values = Valeur
serie.Name = nom
Set serie = Nothing
DoEvents
End Sub


Any help would be grately appreciate.

I'm sure that there is a way to workaround this; I couldn't believe that no
one has ever done an auto-generation graph macro.


Thanks,
Vincent



  #2   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.crashesgpfs,microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Generation of graphs from a template sheet crashes with VBA

Also see the responses to the same problem posted in .charting under
the title "graph troubles in VBA macros"

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Hello,

I'm having troubles with creating some graphs with an Excel VBA Macro.

I would like to create about 35 graphs from a set of data stored in a unique
datasheet. As the set of data can change (length, numbers, etc ..) I created
a macro to generate the graph starting from a template graph.

The macro runs correctly a few times but after a variable number of graph
(from 5 to 15, it depends on the weather), it crashes with :
Run-Time Error '-2147417848 (80010108)' : Methode 'XValues' of object
'series' failed

If i go in debug mode and repeat the error, I get :
Run-Time Error '1004' Unable to set the XValues property of the Series
class.

After this error, excel has always a strange behavior (unable to select
cells), and it always finishes by an excel crash.

I've tried many many things but nothing works :
I'm running Office XP SP2 under Windows 2000. It doesn't work
neither on office 2000 nor office 97 (win95).
I read the Kb article Q210684 about copying sheets . None of the
workaround worked
Save and close the workbook after each graph <- not
working
Import the graph from a template file (sheets.add
type:=template.xlt) <- not working
The codename looks ok (chart1, chart2, chart3, etc .)

I can't create a user-defined style as this worksheet will be
spread on many computers. Even more, the user-defined style can't hold all
information I need (logos, textbox, graph size, ..)

Here is what I do ..

startR is a variable which holds the row number of the dataset's beginning
startC is a variable which holds the colomn number of the dataset's
beginning


For i = 1 To nperfgraph
Sheets("ModelePerf").Copy Befo=Sheets(1)
Set NewGraph = Sheets(1)
NewGraph.Name = "Perf Wet-Dry (" & i & ")"
NewGraph.Axes(1).MinimumScale = Sheets("Data").Cells(startR,
StartC - 2).Value
NewGraph.Axes(1).MaximumScale = Sheets("Data").Cells(startR +
nperfpts, StartC - 2).Value
For j = 1 To nperfcurve
DoEvents
Call BuildSerie(NewGraph, startR, nperfpts, StartC - 2, StartC +
(j + ((i - 1) * nperfcurve)) - 1)
Next j
NewGraph.SeriesCollection(1).Delete
Set NewGraph = Nothing
DoEvents
Next i


Sub BuildSerie(NewGraph, Row, Npts, AxeXC, StartC)

Dim Line As Variant

Data = "=Data!"
Set serie = NewGraph.SeriesCollection.NewSeries
x = Data & "r" & Row & "c" & AxeXC & ":r" & Row + Npts & "c" & AxeXC
Valeur = Data & "r" & Row & "c" & StartC & ":r" & Row + Npts & "c" & StartC
nom = Data & "r" & Row - 2 & "c" & StartC
serie.XValues = x <--------------------- Macro crashes here.
serie.Values = Valeur
serie.Name = nom
Set serie = Nothing
DoEvents
End Sub


Any help would be grately appreciate.

I'm sure that there is a way to workaround this; I couldn't believe that no
one has ever done an auto-generation graph macro.


Thanks,
Vincent




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
How can I create my own template for graphs for easy reuse? Bailey Charts and Charting in Excel 1 November 19th 09 11:59 AM
excel spread sheet crashes davem3675 Excel Discussion (Misc queries) 0 October 19th 09 09:16 PM
MS EXCEL SHEET CRASHES WHEN VIEWING Wally Excel Discussion (Misc queries) 1 September 7th 05 03:02 PM
Automatic filename generation template Astrodude Excel Discussion (Misc queries) 0 April 6th 05 06:19 AM
Excel 2000 crashes when downloading from MS Template Gallery Ladybug Excel Discussion (Misc queries) 0 February 25th 05 06:05 PM


All times are GMT +1. The time now is 11:11 AM.

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"