Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to create chart using VB 6.0

Hi

I try to create a simple line-chart from external program in Visual Basic
6.0. I already generate a quite complex Excel sheet without problems, but
when I try to add chart into this sheet, I don't see anything.

Can you check my code in case of errors? In general, when I created this
code, I followed Macro Recorder and existing code (dynamic series updating
on existing chart).


oExcel.GetWorkbook.Sheets("Main_Wykres").Charts.Ad d
With oExcel.GetExcel.ActiveChart
.ChartType = xlLine
.SetSourceData
Source:=oExcel.GetWorkbook.Sheets("Main_Macierz"). Range("B2:AK16"),
PlotBy:=xlRows
.SeriesCollection(1).Name = Cells(2, 1)
.SeriesCollection(1).XValues = Range("B1:AK1")

For intSeria = 2 To 16
.SeriesCollection.NewSeries.Name = Cells(intSeria, 1)
.SeriesCollection.NewSeries.XValues = Range("B1", "AK1")
.SeriesCollection.NewSeries.Values = Range("B" & intSeria &
":AK" & intSeria)
Next

.Location Whe=xlLocationAsNewSheet
'.Location Whe=xlLocationAsObject, Name:="Main_Wykres"
.HasTitle = True
.ChartTitle.Text = "Multi Trend"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False

.Refresh
End With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to create chart using VB 6.0

These articles show how to do it from Access - it would be the same from VB6.
Looking at your code, your GetExcel and GetWorkbook commands don't sound
like anything you would use in VB6.

http://support.microsoft.com/default...b;en-us;184273
ACC97: How to Use Automation to Create a Microsoft Excel Chart

http://support.microsoft.com/default...b;en-us;202169
ACC2000: Using Automation to Create a Microsoft Excel Chart
(Pretty much the same article as above)

--
Regards,
Tom Ogilvy


"Tomasz Klim" wrote:

Hi

I try to create a simple line-chart from external program in Visual Basic
6.0. I already generate a quite complex Excel sheet without problems, but
when I try to add chart into this sheet, I don't see anything.

Can you check my code in case of errors? In general, when I created this
code, I followed Macro Recorder and existing code (dynamic series updating
on existing chart).


oExcel.GetWorkbook.Sheets("Main_Wykres").Charts.Ad d
With oExcel.GetExcel.ActiveChart
.ChartType = xlLine
.SetSourceData
Source:=oExcel.GetWorkbook.Sheets("Main_Macierz"). Range("B2:AK16"),
PlotBy:=xlRows
.SeriesCollection(1).Name = Cells(2, 1)
.SeriesCollection(1).XValues = Range("B1:AK1")

For intSeria = 2 To 16
.SeriesCollection.NewSeries.Name = Cells(intSeria, 1)
.SeriesCollection.NewSeries.XValues = Range("B1", "AK1")
.SeriesCollection.NewSeries.Values = Range("B" & intSeria &
":AK" & intSeria)
Next

.Location Whe=xlLocationAsNewSheet
'.Location Whe=xlLocationAsObject, Name:="Main_Wykres"
.HasTitle = True
.ChartTitle.Text = "Multi Trend"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False

.Refresh
End With



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default How to create chart using VB 6.0

yes thankx. but my problem is that i just dont know how to refer to cell
"dynamically". e.g. in the example you refered to they write:

Source:=Sheets("Sheet1").Range("C3").CurrentRegion

what i want to know is how you refer to a cell in antother way than Range.
since my cell is variable I want to refer to it in a way so that i can write
(this is not really code im just saying what i want to do..)

(x,y) = rng.Address -----i.e. get the adress from a cell and store it in x
and y. x for rows and y columns or vice versa.
then i want to e.g. add 3 to rows i want to write: x=x+3
making the chart then is easy if you can refer to it as Range(x,y). There is
a function Cells or something but i really dont know how to fix it.
desperatly needs help. !!!!




"Tom Ogilvy" skrev:

These articles show how to do it from Access - it would be the same from VB6.
Looking at your code, your GetExcel and GetWorkbook commands don't sound
like anything you would use in VB6.

http://support.microsoft.com/default...b;en-us;184273
ACC97: How to Use Automation to Create a Microsoft Excel Chart

http://support.microsoft.com/default...b;en-us;202169
ACC2000: Using Automation to Create a Microsoft Excel Chart
(Pretty much the same article as above)

--
Regards,
Tom Ogilvy


"Tomasz Klim" wrote:

Hi

I try to create a simple line-chart from external program in Visual Basic
6.0. I already generate a quite complex Excel sheet without problems, but
when I try to add chart into this sheet, I don't see anything.

Can you check my code in case of errors? In general, when I created this
code, I followed Macro Recorder and existing code (dynamic series updating
on existing chart).


oExcel.GetWorkbook.Sheets("Main_Wykres").Charts.Ad d
With oExcel.GetExcel.ActiveChart
.ChartType = xlLine
.SetSourceData
Source:=oExcel.GetWorkbook.Sheets("Main_Macierz"). Range("B2:AK16"),
PlotBy:=xlRows
.SeriesCollection(1).Name = Cells(2, 1)
.SeriesCollection(1).XValues = Range("B1:AK1")

For intSeria = 2 To 16
.SeriesCollection.NewSeries.Name = Cells(intSeria, 1)
.SeriesCollection.NewSeries.XValues = Range("B1", "AK1")
.SeriesCollection.NewSeries.Values = Range("B" & intSeria &
":AK" & intSeria)
Next

.Location Whe=xlLocationAsNewSheet
'.Location Whe=xlLocationAsObject, Name:="Main_Wykres"
.HasTitle = True
.ChartTitle.Text = "Multi Trend"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False

.Refresh
End With



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to create chart using VB 6.0

assuming rng is a reference to a single cell, for illustration, assume C3

rng.resize(3,1) ' C3:C5

rng.offset(1,0) ' C4

rng.offset(1,0).Resize(3,1) 'C4:C6

--
Regards,
Tom Ogilvy


"april27" wrote:

yes thankx. but my problem is that i just dont know how to refer to cell
"dynamically". e.g. in the example you refered to they write:

Source:=Sheets("Sheet1").Range("C3").CurrentRegion

what i want to know is how you refer to a cell in antother way than Range.
since my cell is variable I want to refer to it in a way so that i can write
(this is not really code im just saying what i want to do..)

(x,y) = rng.Address -----i.e. get the adress from a cell and store it in x
and y. x for rows and y columns or vice versa.
then i want to e.g. add 3 to rows i want to write: x=x+3
making the chart then is easy if you can refer to it as Range(x,y). There is
a function Cells or something but i really dont know how to fix it.
desperatly needs help. !!!!




"Tom Ogilvy" skrev:

These articles show how to do it from Access - it would be the same from VB6.
Looking at your code, your GetExcel and GetWorkbook commands don't sound
like anything you would use in VB6.

http://support.microsoft.com/default...b;en-us;184273
ACC97: How to Use Automation to Create a Microsoft Excel Chart

http://support.microsoft.com/default...b;en-us;202169
ACC2000: Using Automation to Create a Microsoft Excel Chart
(Pretty much the same article as above)

--
Regards,
Tom Ogilvy


"Tomasz Klim" wrote:

Hi

I try to create a simple line-chart from external program in Visual Basic
6.0. I already generate a quite complex Excel sheet without problems, but
when I try to add chart into this sheet, I don't see anything.

Can you check my code in case of errors? In general, when I created this
code, I followed Macro Recorder and existing code (dynamic series updating
on existing chart).


oExcel.GetWorkbook.Sheets("Main_Wykres").Charts.Ad d
With oExcel.GetExcel.ActiveChart
.ChartType = xlLine
.SetSourceData
Source:=oExcel.GetWorkbook.Sheets("Main_Macierz"). Range("B2:AK16"),
PlotBy:=xlRows
.SeriesCollection(1).Name = Cells(2, 1)
.SeriesCollection(1).XValues = Range("B1:AK1")

For intSeria = 2 To 16
.SeriesCollection.NewSeries.Name = Cells(intSeria, 1)
.SeriesCollection.NewSeries.XValues = Range("B1", "AK1")
.SeriesCollection.NewSeries.Values = Range("B" & intSeria &
":AK" & intSeria)
Next

.Location Whe=xlLocationAsNewSheet
'.Location Whe=xlLocationAsObject, Name:="Main_Wykres"
.HasTitle = True
.ChartTitle.Text = "Multi Trend"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False

.Refresh
End With



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 to create chart newby1273 Charts and Charting in Excel 1 April 29th 08 11:54 PM
create line chart with two axises in Pivot Chart HuaXC Charts and Charting in Excel 1 February 21st 07 08:28 PM
How do I create this chart? MEL101060 Charts and Charting in Excel 1 November 16th 06 04:13 PM
Chart data file lost - need to re-create from chart? LostExcelData Charts and Charting in Excel 1 June 7th 06 07:54 PM
Create a combo chart with two of the same chart types Mark Parent Charts and Charting in Excel 2 October 14th 05 01:28 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"