Hello,
I've been coding in Access VBA to create an Excel Graph and it was good.
Until I got this error: 1004 Unable to set the Values property of the Series class
Please check the code below: -
Private Sub TestGraph3()
-
-
Dim oXL As Excel.Application ' Excel application
-
Dim oBook As Excel.Workbook ' Excel workbook
-
Dim oSheet As Excel.Worksheet ' Excel Worksheet
-
Dim oChart As Excel.Chart ' Excel Chart
-
-
Dim myRange As String
-
Dim xlSourceRange As Excel.Range
-
-
Dim iRow As Integer ' Index variable for the current Row
-
Dim iCol As Integer ' Index variable for the current Row
-
-
Const cNumCols = 4 ' Number of points in each Series
-
Const cNumRows = 5 ' Number of Series
-
-
ReDim aTemp(1 To (cNumRows + 1), 1 To cNumCols)
-
-
' Start Excel and create a new workbook
-
Set oXL = CreateObject("Excel.application")
-
Set oBook = oXL.Workbooks.Add
-
-
Set oSheet = oBook.Worksheets.Item(1)
-
-
' Insert data into Cells for the two Series:
-
For iCol = 1 To cNumCols
-
aTemp(1, iCol) = "A" & iCol
-
aTemp(2, iCol) = 1
-
aTemp(3, iCol) = 1 + 2
-
aTemp(4, iCol) = iCol
-
-
If (iCol * 2) <= cNumCols Then
-
aTemp(5, iCol) = iCol * 2
-
Else
-
aTemp(5, iCol) = cNumCols
-
End If
-
Next iCol
-
-
oSheet.Range("A1").Resize(5, cNumCols).Value = aTemp
-
-
oSheet.Name = "MyChart_MD"
-
-
myRange = "A1:D" & (cNumRows)
-
Set xlSourceRange = oBook.Worksheets(1).Range(myRange)
-
-
Set oChart = oXL.Charts.Add
-
-
With oChart
-
.SetSourceData Source:=xlSourceRange, PlotBy:=xlColumns
-
.ApplyCustomType ChartType:=xlBuiltIn, TypeName:="Line - Column"
-
-
.SeriesCollection(1).XValues = oSheet.Range("A1").Resize(1, cNumCols)
-
.SeriesCollection(1).Values = oSheet.Range("A2").Resize(1, cNumCols)
-
.SeriesCollection(1).Name = "Plan"
-
.SeriesCollection(2).Values = oSheet.Range("A3").Resize(1, cNumCols)
-
.SeriesCollection(2).Name = "Actual"
-
.SeriesCollection(3).Values = oSheet.Range("A4").Resize(1, cNumCols)
-
.SeriesCollection(3).Name = "Accu. Plan"
-
.SeriesCollection(4).Values = oSheet.Range("A5").Resize(1, cNumCols)
-
.SeriesCollection(4).Name = "Accu. Actual"
-
.Location Where:=xlLocationAsNewSheet, Name:="chartMD"
-
-
.HasTitle = True
-
.ChartTitle.Characters.Text = "Chart : MD"
-
.Axes(xlCategory, xlPrimary).HasTitle = False
-
.Axes(xlValue, xlPrimary).HasTitle = True
-
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Accu."
-
.Axes(xlCategory, xlSecondary).HasTitle = False
-
.Axes(xlValue, xlSecondary).HasTitle = False
-
-
.HasLegend = False
-
.HasDataTable = True
-
.DataTable.ShowLegendKey = True
-
End With
-
-
' Make Excel Visible:
-
oXL.Visible = True
-
oXL.UserControl = True
-
' Unselect the ActiveChart
-
oChart.Deselect
-
oXL.ActiveWindow.Zoom = 85
-
-
' Protect whole Worksheet
-
oSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
-
-
' Clean-up
-
Set oXL = Nothing: Set oChart = Nothing: Set oSheet = Nothing: Set oBook = Nothing
-
-
End Sub
-
If cNumCols = 3, ERROR occurs in this line: -
.SeriesCollection(4).Values = oSheet.Range("A5").Resize(1, cNumCols)
-
If cNumCols = 2, ERROR occurs in this line: -
.SeriesCollection(3).Values = oSheet.Range("A5").Resize(1, cNumCols)
-
cNumCols is supposed to be the number of points in each series.
Not the number of series.
cNumRows is the number of series.
In a situation where there are 4 Series (Actual, Plan, Accu. Actual, Accu. Plan)
how can I display a graph/chart with 3 columns only?
Help will be greatly appreciated.
4 5922 NeoPa 32,579
Recognized Expert Moderator MVP
I can't help with this I'm afraid, but I have a couple of suggestions as to how you can make your question more attractive to potential responders. - When you have a large amount of code to post, please do the legwork first to remove anything which is not relevant to the problem. Produce the smallest set of code that you can which still exhibits the problems you're suffering from.
Simply dumping your native code in for someone else to go through won't win you many friends. - The [ CODE ] tags you've used add line numbers when they display. When referring to lines in your code it is most easy to do this by the line number.
I would just add that, while point number one is about courtesy, it also has the added benefit of giving you a better understanding of your own code as you process through deciding what to strip. In fact it's fairly common during this process to discover for yourself the problem you're posting to find.
Good luck anyway with your question.
I can't help with this I'm afraid, but I have a couple of suggestions as to how you can make your question more attractive to potential responders.- When you have a large amount of code to post, please do the legwork first to remove anything which is not relevant to the problem. Produce the smallest set of code that you can which still exhibits the problems you're suffering from.
Simply dumping your native code in for someone else to go through won't win you many friends. - The [ CODE ] tags you've used add line numbers when they display. When referring to lines in your code it is most easy to do this by the line number.
I would just add that, while point number one is about courtesy, it also has the added benefit of giving you a better understanding of your own code as you process through deciding what to strip. In fact it's fairly common during this process to discover for yourself the problem you're posting to find.
Good luck anyway with your question.
Thank you NeoPa for the advice.
I posted them all so others could easily test.
I understand it is not their job to test but to give advice.
I will keep that in mind.
...and I'm still stuck in this weirdness of this Chart's Series Class.
Finally solved the intermittent problem!
Acknowledgment goes to Mr. Jon Peltier.
He's very helpful and yet an expert in this field.
Line and XY charts don't like it when a series starts with no data.
He's advice is to set Chart Type to xlColumnCluster ed which will
set blank data into valid ones. Then, re-insert the original line
after setting all the data.
Let's base from the above code.
The following lines must be changed from this: -
....
-
.SetSourceData Source:=xlSourceRange, PlotBy:=xlColumns
-
.ApplyCustomType ChartType:=xlBuiltIn, TypeName:="Line - Column"
-
....
-
...into this: -
....
-
.ChartType = xlColumnClustered
-
.SetSourceData Source:=xlSourceRange
-
....
-
Not only the Chart Type and the sequence of the lines have changed
but the SetSourceData as well.
Note:
Not changing the sequence of lines seems not to fix the problem.
It only takes longer time before the error occurs again.
Don't have explanation on this yet.
Now, after modifying as stated above, let's re-insert the original line: -
....
-
.SeriesCollection(4).Name = "Accu. Actual"
-
.ApplyCustomType ChartType:=xlBuiltIn, TypeName:="Line - Column" ' <-- this one!
-
.Location Where:=xlLocationAsNewSheet, Name:="chartMD"
-
....
-
Eureka!
Intermittent problem gone.
Hope this helps you the way it helped much to me!
keirnus
NeoPa 32,579
Recognized Expert Moderator MVP
Thank you for the answer Keirnus. That's much appreciated.
My earler point, about stripping down the code, was about setting up a test rig rather than simply cutting out what you post from your code. To be honest, although we'd appreciate that method, we very rarely come across it, so don't worry too much (although I would still maintain it often proves a very real benefit to the poster).
Anyway, your posted solution (so clearly explained too) should prove very helpful, so full marks for that :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Arun Nair |
last post by:
Hi,
I have the following jsp page. I am able to view only a part of
it(until the occurence of the first City text box). If i remove the
first few fields from the page, I am able to see a few more fields at
the bottom.
My form class contains all the properties that are used in the jsp
page.
I don't know what I am doing wrong. I am using struts1.1 & JDK
1.4.2.
|
by: ssb |
last post by:
Hello,
This may be very elementary, but, need help because I am new to access
programming.
(1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor
?) the values one by one and populate a combo box with these names.
(this way, I can display all the EMPLOYEE_NAME values)
(2) In general, can I do additional processing on column values from
|
by: Edward Diener |
last post by:
I am gathering from the documentation that return values from __events are
not illegal but are frowned upon in .NET. If this is the case, does one pass
back values from an event handler via "in/out" or "out" parameters ? Or is
it simply that events are just notifications and are not interested in any
values which event handlers might be able to return ?
If the latter is the case, the event model in .NET appears to have a great...
|
by: Chris Bower |
last post by:
Reposted from aspnet.buildingcontrols:
Ok, I've got a bunch of derived controls that all have a property Rights of
type Rights (Rights is an Enumerator). I wrote a custom TypeConverter so
that I can use comma separated values in design-time. The TypeConverter
works great in design-time. It converts to and from just fine... However,
when I try to load any page in the site now I get the following error
(Following the error is code for the...
|
by: epatrick |
last post by:
I have a series of custom controls developed under ASP.NET 1.1, and
I've successfully migrated to ASP.NET 2.0. I have also developed a
custom class dervied from System.Web.UI.Page, called qbo.Web.Page.
All of these controls compile and run correctly under ASP.NET 2.0.
However, several of these controls throw an error in the design mode
of VS.NET 2005. Specifically, controls that include a property
override of Page (to cast as a...
| |
by: bhanubalaji |
last post by:
hi,
I am unable to disable the text(label) in javascript..it's working fine with IE,but i am using MOZILLA..
can any one help regarding this..
What's the wrong with my code?
I am sending my code here..
Thanks in Advance...
Regards
|
by: forgedascendant |
last post by:
Good day everyone,
I am new to this site so please forgive me if this post isn't completly correct. For the past 2 weeks I have been beating my head against the wall trying to figure out what is wrong with the macro I created. The problem I am experiancing is that the range I am trying to put together does not seem to be working for some reason. My entire code is as follows:
Sub Proto1()
'
' Proto1 Macro
' Macro recorded 8/30/2007...
|
by: =?Utf-8?B?Umljaw==?= |
last post by:
I have seen examples of passing data from FormB to FormA (Parent To Child)
but I need an example of passind data from FormA to FormB. My main form is
FormA; I will enter some data in textboxes and click a button to bring up
FormB which needs to display values entered in FormA.
Thanks in advance.
|
by: Andy B |
last post by:
I have the following listView control on a page:
<asp:ListView ID="ListView1" runat="server"
ItemPlaceholderID="PlaceHolder1">
<ItemTemplate>
<dl>
<dt>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |