31
Draw A Horisontal Line In Excel Chart With Only One Column I'm trying to draw a horisontal line in an excel ColumnClustered chart and this works fine, except for the case where there is only one column. Logical, I know. It's difficult to draw a line based on only one point. Any ideas on how to get around this? Public gChartObject As Excel.ChartObject Private Sub fixthegraph(ByVal excelrange As String, ByVal timeInterval As Integer, ByVal timeType As String) Dim i As Integer Dim myAxis As Axis Dim range As String 'fix range range = "a1:" & excelrange & "5" gChartObject.Name = "Result" For i = 2 To 5 gChartObject.Chart.SeriesCollection.Add source:=gXlDataSheet.range("a" & i & ":" & excelrange & i) Next i gChartObject.Chart.SeriesCollection(1).XValues = gXlDataSheet.range("b1:" & excelrange & "1") gChartObject.Chart.ChartType = xlLine gChartObject.Chart.HasDataTable = True gChartObject.Chart.HasLegend = False gChartObject.Chart.SeriesCollection(1).ChartType = xlColumnClustered If frmMain.lstChosenAreas.ListCount < 2 Then ' only show target line (red) if one chosen area... gChartObject.Chart.SeriesCollection(3).Border.Color = RGB(255, 0, 0) gChartObject.Chart.SeriesCollection(3).Border.Weight =

Draw A Horisontal Line In Excel Chart With Only One Column

Embed Size (px)

Citation preview

Page 1: Draw A Horisontal Line In Excel Chart With Only One Column

Draw A Horisontal Line In Excel Chart With Only One Column I'm trying to draw a horisontal line in an excel ColumnClustered chart and this works fine, except for the case where there is only one column. Logical, I know. It's difficult to draw a line based on only one point. Any ideas on how to get around this?

Public gChartObject As Excel.ChartObject

Private Sub fixthegraph(ByVal excelrange As String, ByVal timeInterval As Integer, ByVal timeType As String)    Dim i As Integer        Dim myAxis As Axis    Dim range As String        'fix range    range = "a1:" & excelrange & "5"

    gChartObject.Name = "Result"        For i = 2 To 5      gChartObject.Chart.SeriesCollection.Add source:=gXlDataSheet.range("a" & i & ":" & excelrange & i)    Next i    gChartObject.Chart.SeriesCollection(1).XValues = gXlDataSheet.range("b1:" & excelrange & "1")        gChartObject.Chart.ChartType = xlLine    gChartObject.Chart.HasDataTable = True    gChartObject.Chart.HasLegend = False        gChartObject.Chart.SeriesCollection(1).ChartType = xlColumnClustered        If frmMain.lstChosenAreas.ListCount < 2 Then        ' only show target line (red) if one chosen area...        gChartObject.Chart.SeriesCollection(3).Border.Color = RGB(255, 0, 0)        gChartObject.Chart.SeriesCollection(3).Border.Weight = xlThick                ' ??????? what to do if only ONE column???????            Else        ' hide da line, aiiight?                gChartObject.Chart.SeriesCollection(3).Border.Color = RGB(0, 0, 0)        gChartObject.Chart.SeriesCollection(3).Border.Weight = xlHairline    End If    gChartObject.Chart.SeriesCollection(4).Border.ColorIndex = xlColorIndexNone

Page 2: Draw A Horisontal Line In Excel Chart With Only One Column

    gChartObject.Chart.SeriesCollection(2).Border.ColorIndex = xlColorIndexNone                'do some stuff...        ' now, copy chart to clipboard         gChartObject.Chart.CopyPicture        ' and paste it to the form        Me.Picture = Clipboard.GetData        Me.Show    Screen.MousePointer = vbNormalEnd Sub

 

Edited by - agyl on 5/3/2004 2:24:12 AM

How To Copy A Chart From One OLE Excel Sheet To An OLE Excel Chart Object Hi all,

Kinda stuck here and I have been searching for the way to do this all day. I have a spreadsheet with Charts in one VB OLE container (Excel.Sheet.8)and I want to copy one of the charts to another VB OLE container (Excel.Chart.8) and have it sized to fit in my OLE container. I cant seem to get it to work. Any help?

Where OLE1 = spreadsheets with chartsand OLE2 is a chart

Code:OLE1.Class = "Excel.Sheet.8"OLE1.SourceDoc = App.Path & "Data5.xlt"OLE1.Action = 0'... Work with the spreadsheet...OLE2.Class = "Excel.Chart.8"OLE2.Action = 0Set OLE2.object = OLE1.object.Charts(1) 'Doesnt WorkOLE2.object.Height = 5000 'Doesnt WorkOLE2.object.Width = 10000

USing Data To Draw Org Chart apologies if this has been posted before.

I have a data structure in access, 2 tables, one detailing forms from a 3rd party application, name and title, the other showing the parent child relationships.

Page 3: Draw A Horisontal Line In Excel Chart With Only One Column

I wanted to quickly download an application which would read in these data and draw me an org chart so that we can see the menu structure for testing purposes. (there are 1000's of forms so doing this manually is not an option).

On failing to find anything through google i decided to record some power point macro's whilst inserting an Org chart, changing text, adding nodes etc.

The code I recorded is horrible to read, where i entered data in 3 branches it all appears in the code as one string.

So i tried in excel, with which i am more familiar with VBA, and in excel XP you cannot perform any org chart actions while recording a macro.

so can anybody help me learn to manipulate an org chart object through VB, to send it the data i want it to draw

macro code: i inserted a chart, and entered "Top" in the top level, one, two and three in the 2nd tier and i added a node under three and added "three_1"

Code:ActiveWindow.Selection.SlideRange.Shapes("Group 5").SelectActiveWindow.Selection.ShapeRange.GroupItems(Index:=10).TextFrame.TextRange.Characters(Start:=1, Length:=0).SelectWith ActiveWindow.Selection.TextRange.Text = "three_1threetwoonetop"With .Font.Name = "Arial".Size = 18.Bold = msoFalse.Italic = msoFalse.Underline = msoFalse.Shadow = msoFalse.Emboss = msoFalse.BaselineOffset = 0.AutoRotateNumbers = msoFalse.Color.SchemeColor = ppForegroundEnd WithEnd WithActiveWindow.Selection.SlideRange.Shapes("Organization Chart 5").Select

its this bit which confused me:.Text = "three_1threetwoonetop"

Page 4: Draw A Horisontal Line In Excel Chart With Only One Column

i suppose in the worst case scenario i could do this with a txt string converting the data to a HTML table but would I prefer a nice easy and elegant solution.

How To Draw Xy Chart Using MSChart? hi,i have an array with 10 values, and i want to draw it in a chart using Mschart.. xy chart is my target so how can i do it

Draw Chart And Db Design Using the tutorial from this site, I made a simple chess rating calculator. Question:

1. After typing "a" to search for Hafiz Shafruddin for example, a list of names with letter "a" will appear on the combobox. How can I make player's rating textbox automatically filled with 2100 when I double click/single click "Hafiz Shafruddin"? (read from the database)

2. I wanted to make a player's graph performance.    How do I design the database so that there will be records of each player's rating for a given date? Then, how to draw a graph rating fluctuations of the last 10 games for a player?

How I Can Draw A Curve With Ms Chart Control In Vb6 i need help for the drawing curve with the ms chart control with five points and also i want to calculate the intersection point of the two different curve.plz help me how to use ms chart control in my vb application. i haven't use ms chart control before.

How To Draw On One Chart, Line And Histogram??? Hello i have a simple question, i want to draw on one chart two series,or in other word two lines.Then after the user press on a button, I want that one line will convert to 2dbar or any other possible like 3darea and so one.

I found out that there is a code for controlling the series and like you can change the chart type with the code:MSChart1.chartType = VtChChartType3dStep

you can change the series with the codeMSChart1.Plot.SeriesCollection(Series).SeriesType = VtChSeriesType2dBar

the only problem is that its not working how then can it be done?

janiv

How To Draw A Chart Using Data From Database? my database file contains a table, how can i draw a chart using the data from the table in the database?

Page 5: Draw A Horisontal Line In Excel Chart With Only One Column

MS Chart Reliability - Radar Chart / 3D Pie Chart I see a lot of issues with MS chart.... I'm mostly coding my charts (not using MS Chart), but I'm stuck with the Radar Chart ... I haven't found any examples to work on and I need this chart badly (a polygon with nine corners - a nonagon).

Any feedback on MS Chart? Is it reliable and stable? If it is I might end up using it to create my radar chart, but I'm not sure MS Chart can make a Radar Chart... if not then:

The image I've attached shows what I want to code.

Does anybody have any code regarding a RADAR CHART? (not an Active X, source code)

Thanks

_________________________________________________________________

Edited by - vbprog1144 on 5/19/2005 11:48:26 AM

Embedded Chart In A Worksheet And A Chart Exisiting On Its Own Sheet what is the difference between a Chart embedded in a worksheet and a chart existing on their own sheets. i mean what is the difference between being embedded in a worksheet and existing on their own sheets.

i came across the statement on the MSDN site

Note Charts embedded in a worksheet are members of the ChartObjects collection, whereas charts that exist on their own sheets belong to the Charts collection.

Is There A Good Graph/Chart Tool Anywhere??? MS Chart Isn't Working For Me!!! I need to graph 4 columns of data against a time (x-axis) produced from a SQL select in VS.net. I've tried working with the MS chart, but its hard to work with and looks even worse.

I'm looking for something that can produce a "smooth" line chart.

Does anyone know of a GOOD graph/chart tool compatible with VS.net (windows app though, not Web app.)???

And if it is a free tool, that would be even better!!!

Julez

Create Chart In Access Using Chart Object Code:

Dim rpt As Access.ReportDim ctlObjFrame As Access.ObjectFrame

Page 6: Draw A Horisontal Line In Excel Chart With Only One Column

Dim SQL As StringDim cw_rs As DAO.Recordset

SQL = "SELECT (Format([Date1],'DDDDD')),Sum([Events]) AS [SumOfEvents] FROM [Data] GROUP BY (Int([Date1])),(Format([Date1],'DDDDD'))"Set rpt = CreateReportSet ctlObjFrame = CreateReportControl(rpt.Name, acObjectFrame, , "", "", 100, 100)Set cw_rs = CodeDb.OpenRecordset(SQL, dbopendynaset)cw_rs.MoveFirstctlObjFrame.OleData= cw_rs!ChartObjectDoCmd.RestoreI got the above code from a site. It creates a new report & an objectFrame. But during run-time it gives error in "ctlObjFrame.OleData" as "Items not found in the collections" error. Can anyone please tell me why i get this error.

Chart Director Chart Viewer i have a sample code here for my graph:

Public Sub createChart(viewer As Object, img As String)

Dim cd As New ChartDirector.APIDim i As Integer'The XY points for the scatter chartDim dataX0()dataX0 = Array(summationx)Dim dataY0()dataY0 = Array(summationy)

' Dim dataX1((frminput.txtx(i - 1)))' dataX1 = Array((frminput.txty(i - 1)))'' Dim dataY1()' dataY1 = Array()

'Create a XYChart object of size 450 x 420 pixelsDim c As XYChartSet c = cd.XYChart(1000, 1000)

'Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey'border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light'grey color (0xc0c0c0)Call c.setPlotArea(55, 65, 350, 300, -1, -1, &HC0C0C0, &HC0C0C0, -1)

'Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12'pts Times Bold Italic font. Set the background and border color to Transparent.

Page 7: Draw A Horisontal Line In Excel Chart With Only One Column

Call c.addLegend(50, 30, False, "timesbi.ttf", 12).setBackground(cd.Transparent)

'Add a title to the chart using 18 pts Times Bold Itatic font.'Call c.addTitle("Center of Gravity", "timesbi.ttf", 18)

'Set the axes line width to 3 pixelsCall c.xAxis().setWidth(3)Call c.yAxis().setWidth(3)

'Add an orange (0xff9933) scatter chart layer, using 13 pixel diamonds as symbols

For i = 0 To UBound(arrX)Call c.addScatterLayer(arrX, arrY, "", cd.DiamondSymbol, 13, &HFF9933)Next

'Add a green (0x33ff33) scatter chart layer, using 11 pixel triangles as symbolsCall c.addScatterLayer(dataX0, dataY0, "Strategic Area", cd.TriangleSymbol, 13, _&H33FF33)

'output the chartSet viewer.Picture = c.makePicture()

'include tool tip for the chartviewer.ImageMap = c.getHTMLImageMap("clickable", "", _"title='[{dataSetName}] X = {x} , Y = {value} '")

End Sub

Private Sub ChartViewer1_ClickHotSpot(hotSpot As Collection, Button As Integer, Shift As Integer, X As Single, Y As Single)

End Sub

Private Sub Command1_Click()frminput.ShowUnload Me

End Sub

Private Sub Form_Load()createChart Me.ChartViewer1.Object, Me.Picture1End Sub

but it seems that when ever i would put a label for the the orange point in my graph it would

Page 8: Draw A Horisontal Line In Excel Chart With Only One Column

multiply itself like it is being arrayed. i know its kinda confusing but if you want i could post my whole program here so that you could all understand me. thanx!!!

Save A Chart Using Chart Director Have anyone here use a activeX call Chart Director to create chart? I've successful create the chart i want but i cant seem to save the file. Here is the code i got for the save button:

Code:Private Sub CmdSave_Click()Dim c As XYChartDim strsavefile As StringWith CommonDialog1'.Filter = "Pictures (*.bmp)|*.bmp" .DefaultExt = "JPG".CancelError = False.ShowSavestrsavefile = .FileNameIf strsavefile = "" Then Exit SubEnd With

Call c.makeChart("strsavefile")

End Sub

I keep getting a object or variable not set. How do i fix this?

How To Make A Chart (MS Chart) With Data From A DB???? Hi all,

Can u show me how to have a chart produced from data directly (or indirectly) from a MDB (access2000)???

An example project would be brilliant, or the code???

Please help

Clustered Chart With Stacked Chart hi,

os XP

Page 9: Draw A Horisontal Line In Excel Chart With Only One Column

VB.NET WITH EXCEL 2000

i can creat charts with stacked column.now i need create a chart with a combination of clustered and staked column.how to create it?is it possible with excel 2000 or not?

thankssudarleo

Print Contents Of A CHART (MS CHART) Kindly help me in printing the contents of a Chart control along with the contents of a picture box control. I have the code to print the contents of the Chart. But I want to print a bitmap as the heading of the Chart. This bitmap is assigned to a picture box during runtime. The output should be :The bitmap which will serve as the heading followed by the Chart.Thank you for your time.

K. Ravi

Excel Chart In VB i want to make a form and an exe file after that

where there are 6 text boxes where i key in value and submitwhen i submit the chart also in the same form takes the value and draws the graph.

the chart is an excel chartembedded in the form,

i am able to do this using the VB editor in excellike Sheets("Sheet1").SelectRange("A1").SelectActiveCell.FormulaR1C1 = TextBox1.Value

Chart1. is the object in my formhow do i call it and select the sheet1 and do the same like i did in excel

please help, i also tried the OLE way, but also not sure how to do

thanks,darcher

Excel Chart I've been working on an excel file for a while and have been getting quite a bit of help from everyone here. I added a chart to my file and I wanted to tweak it a little. The Y axis is in

Page 10: Draw A Horisontal Line In Excel Chart With Only One Column

seconds and I would like to have a red line drawn all the way across the chart at the 60 seconds mark. As I said before the y axis is seconds and it changes if I have large or small amounts for in my series. Sometimes it goes from 0 to 100 or sometimes its from 0 to 2000. So as you can see the red line will need to move up and down as the chart changes.

Is this even posible?

If not, Thanks anyway.

Excel Chart Ok ... i currently have my code drawing from an array with 2 cols .. this produces a chart with the two sets of variables plotted on the y axis against incremental x values that excel has set up (ie 1 2 3 4 ....)

Now .. what i want to do is keep the 2 y series ... but make the x axis my own values.....

here is my code

Dim Counter As Integer

Counter = 1Do While Counter <= NgrdAnalytical.Row = CountergrdAnalytical.Col = 2grdAnalytical.Text = MatrixOutput(Counter)arrOut(2, Counter) = MatrixOutput(Counter)Counter = Counter + 1

Loop

'------------Excel Chart---------------------------------------'

Dim oXL As Object ' Excel applicationDim oBook As Object ' Excel workbookDim oSheet As Object ' Excel WorksheetDim oChart As Chart ' Excel Chart

Dim iRow As Integer ' Index variable for the current RowDim iCol As Integer ' Index variable for the current Row

Dim cNumCols As Integer ' Number of points in each SeriesDim cNumRows As Integer ' Number of Series

Page 11: Draw A Horisontal Line In Excel Chart With Only One Column

cNumRows = 2cNumCols = N

ReDim aTemp(1 To cNumRows, 1 To cNumCols)

'Start Excel and create a new workbookSet oXL = CreateObject("Excel.application")Set oBook = oXL.Workbooks.AddSet oSheet = oBook.Worksheets.Item(1)

oSheet.Range("A1").Resize(cNumRows, cNumCols).Value = arrOut

'Add a chart object to the first worksheetSet oChart = oSheet.ChartObjects.Add(50, 40, 400, 300).Chart

With oChart 'or you could use ActiveChart

.ChartType = xlLine

.SetSourceData Source:=oSheet.Range("A1").Resize(cNumRows, cNumCols)

.HasTitle = True

.ChartTitle.Characters.Text = "Method Comparison"

.Axes(xlCategory, xlPrimary).HasTitle = True

.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Node"

.Axes(xlValue, xlPrimary).HasTitle = True

.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Temperature"

.SeriesCollection(1).Name = "=""Analytical"""

.SeriesCollection(2).Name = "=""Finite Differences"""With oChart.Axes(xlCategory).HasMajorGridlines = True.HasMinorGridlines = TrueEnd WithEnd With

'Make Excel Visible:

oXL.Visible = True

Excel Chart PLEASE PLEASE HELP ! ok ... below is my code ... which does produce a graph just fine ... the problem is trying to add a title or change the graph type ...

i have tried adding

oChart.hasTitle = TRUE

Page 12: Draw A Horisontal Line In Excel Chart With Only One Column

oChart.Title.Caption = "Whatever"

and it always gives me errors .... how can i add a title and change the graph type !! PLEASE

-----------------------------------------------------------------------------------

Dim oXL As Object ' Excel applicationDim oBook As Object ' Excel workbookDim oSheet As Object ' Excel WorksheetDim oChart As Object ' Excel Chart

Dim iRow As Integer ' Index variable for the current RowDim iCol As Integer ' Index variable for the current Row

Dim cNumCols As Integer ' Number of points in each SeriesConst cNumRows = 2 ' Number of Series

cNumCols = N

ReDim aTemp(1 To cNumRows, 1 To cNumCols)

'Start Excel and create a new workbookSet oXL = CreateObject("Excel.application")Set oBook = oXL.Workbooks.AddSet oSheet = oBook.Worksheets.Item(1)

oSheet.Range("A1").Resize(cNumRows, cNumCols).Value = arrOut

'Add a chart object to the first worksheetSet oChart = oSheet.ChartObjects.Add(50, 40, 300, 200).ChartoChart.SetSourceData Source:=oSheet.Range("A1").Resize(cNumRows, cNumCols)

' Make Excel Visible:oXL.Visible = True

oXL.UserControl = True

-------------------------------------------------------------------------------

Note: this example is on the microsoft page ... so you can try adding the title code to that if u want to get it working ... the microsoft example generates a random array...

Page 13: Draw A Horisontal Line In Excel Chart With Only One Column

Excel Chart Hello!i want to combine Excel Chart in my form!the Chart data are stored in recordset(query result).how can i do so?expample wil be nice to have!thank you alot in advance

Excel Chart I have written a VB program which sends a two dimensional array of numbers to an Excel file. This data is then graphed on arrival using VBA code.

How do i make this Excel chart appear on my VB form aswell?

Excel Chart Using ADO? Hi to all thread viewers,

Is there any possibility of creating an excel-chart using "ADO"........

If yes, please give me some hints...

Thank you in advance..

Using The MS Excel Chart In VB - ? Could anyone point me to a good resource for using MS Excel chart in vbor give some sample codes on things like how to change the axis labels /values how to plot points on the graph (multiline) etc

Cheers

Excel Chart In VB hi.

i'm creating an excel chart in VB. In excel, you can set theproperty : "Value(y) crosses between dates" to have excelplot date values in between the tick marks. Setting this propertyto false makes excel plot the date values to correspond to actualtick marks.

Is this property exposed in the Excel object in VB? I need to set thisto false.

Also, how do i add minor tick marks to an excel chartfrom VB?

Thanks, any help would be greatly appreciated.

Page 14: Draw A Horisontal Line In Excel Chart With Only One Column

Excel Chart hi all,

anyhow, using this forum, i managed to create a chart in excel thru vb code. now i want to change few default settings of the chart.

1) i dont want the vertical lines in the chart.2) the y scale must be in numeric format and the x scale must be in date format. but in the chart both the scales or shown in date format. how to set the format for both the scales?3) is it possible to save the excel chart in TIFF or EPS format?

pls guide

regards,

prakash

Excel Chart Hi, i'm trying to do one excel chart trough VB, but i'm not quite getting it. I did one macro and tried to modified her but with almost no result. Can you help me in this:

My macro:///With ObjXLApp

NM = .ActiveSheet.NameN2 = Format(Date, "MMMM") & " " & Format(Date, "yyyy")

.Charts.Add

.ActiveChart.ChartType = xlLineMarkers

.ActiveChart.PlotBy = xlColumns

.ActiveChart.SeriesCollection.NewSeries

.ActiveChart.SeriesCollection(1).XValues = "={""Recolhas""}"

.ActiveChart.SeriesCollection(1).Values = "=NM" & !R2C4: RintNumerOfRows2C4 ""

.ActiveChart.SeriesCollection(1).Name = "=""Último minuto"""

.ActiveChart.SeriesCollection(2).Values = "NM!R2C5:RintNumerOfRows2C5"

.ActiveChart.SeriesCollection(2).Name = "=""Últimos 5 minutos"""

.ActiveChart.SeriesCollection(3).Values = "NM!R2C6:RintNumerOfRows2C6"

.ActiveChart.SeriesCollection(3).Name = "=""Últimos 15 minutos"""

.ActiveChart.Location Where:=xlLocationAsObject, Name:=NM///

Excel Chart hi all,

i am using excel object in my project. i managed to write in the data to the excel worksheet and save it. can any one tell me how to draw a chart in excel thru vb program?

Page 15: Draw A Horisontal Line In Excel Chart With Only One Column

pls guide. its urgent

regards,prakash

Excel Chart Hello,

1. Who can tell me where i can get the reference to use the vb 6.0 to control EXECL to chart.2. If i want to show the EXCEL chart(may be very big) , how i can do?

thanks a lot.

Help With Chart In Excel Hi, I created some code to open up a new Excel workbook that enters information and then creates a pie chart.. I can't quite remember how I put it together, but one part I have is to get letter of the last horizontal cell.. I used this line:

dim LastCell as StringLastCell = Chr(rsStats.RecordCount + Asc("A") - 1)

Then alittle more down, I select the data range:

oChart.SetSourceData Source:=oSheet.Range("A3:" & LastCell & "4"), PlotBy:=xlRows

This is, LastCell seems to work fine with A-Z, but I forgor the possibilty of going beyond Z (AA, AB, etc)..

Does anyone know how to get the name of the horizontal cell from Excel?ThanksJohn

Excel Chart O has already been set up as a excel.applicationI keep getting errors with this...I created it in the macro of Excel but need it to work in VB

O.Charts.AddO.ActiveChart.ChartType = xlLine <-ERRORO.ActiveChart.SetSourceData Source:=O.Sheets("MarketSmart").Range("F1:G" & MScr), PlotBy:=xlColumnsO.ActiveChart.Location here:=xlLocationAsNewSheet, Name:="MS Chart" <-ERRORWith O.ActiveChart.HasTitle = True.ChartTitle.Characters.Text = "MarketSmart"

Page 16: Draw A Horisontal Line In Excel Chart With Only One Column

.Axes(xlCategory, xlPrimary).HasTitle = True

.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"

.Axes(xlValue, xlPrimary).HasTitle = True

.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Defects"End WithO.ActiveChart.HasDataTable = False

HELP!!!!!!

API Excel Chart HELP ME PLEASE!!! I am trying to read data from a .txt file and put certain data into an Excel ole chart in my VB application. Could anyone please point me in the right direction.Many Thanks

Chart In Excel Hi guys, I am very new to VB and this forum so be gentle :-)

How do I create a chart in Excel using VB6?

This is how far I have gotten (this is mostly what I have found on the net)

Sub createExcelGraphs()Dim oXL As Object ' Excel applicationDim oBook As Object ' Excel workbookDim oSheet As Object ' Excel WorksheetDim oChart As Object ' Excel ChartDim iRow As Integer ' Index variable for the number of RowsDim iCol As Integer ' Index variable for the number of Cols

Set oXL = CreateObject("Excel.application")Set oBook = oXL.Workbooks.AddSet oSheet = oBook.Worksheets.Item(1)

Set oChart = oSheet.chartObjects.Add(50, 40, 300, 200).chart

iRow = 10 iCol = 2

' This line gives the error - "Object required"oChart.ChartType = Excel.XlChartType.xlLine

oChart.SetSourceData Source:=oSheet.Range("b1").Resize(iRow, iCol)oXL.UserControl = TrueEnd Sub

Page 17: Draw A Horisontal Line In Excel Chart With Only One Column

I want to create an xlLine graph and be able to chaneg the font on the axis. How do I do this?

Thanks

Need VB5 Help With Excel Chart Hi,

I'm trying to duplicate in VB5 code from Excel 2000 for working with a stock chart.

In Excel VBA, to set a chart type it is:

ActiveChart.ChartType = xlStockOHLC

In VB5, I added the Excel Chart using the OLE object tool.  The object is: OLE1, so I tried:

OLE1.ChartType = xlStockOHLC

but I get a "Method or Data Member Not Found" on the ChartType method.

Its been a long time since I've done coding like this.  Any help appreciated.

Thanks,Brooks

Chart With Excel Hello guys,

I really need your help.....I need to do a chart with VBA/excel, basically the sheet with the values and the chart made by program line.I found this code, but with error in the line....

Code:colCharts.Add()

whats the problem?

CAN YOU GUYS PLEASE HELP ME OUT?

Code:Set objExcel = CreateObject("Excel.Application")    objExcel.Visible = True    Set objWorkbook = objExcel.Workbooks.Add()        Set objWorksheet = objWorkbook.Worksheets(1)

Page 18: Draw A Horisontal Line In Excel Chart With Only One Column

        objWorksheet.Cells(1, 2) = "Monday"    objWorksheet.Cells(1, 3) = "Tuesday"    objWorksheet.Cells(1, 4) = "Wednesday"    objWorksheet.Cells(1, 5) = "Thursday"    objWorksheet.Cells(1, 6) = "Friday"        objWorksheet.Cells(2, 1) = "atl-dc-01"    objWorksheet.Cells(2, 2) = 82    objWorksheet.Cells(2, 3) = 85    objWorksheet.Cells(2, 4) = 91    objWorksheet.Cells(2, 5) = 178    objWorksheet.Cells(2, 6) = 91        objWorksheet.Cells(3, 1) = "atl-dc-02"    objWorksheet.Cells(3, 2) = 104    objWorksheet.Cells(3, 3) = 87    objWorksheet.Cells(3, 4) = 93    objWorksheet.Cells(3, 5) = 100    objWorksheet.Cells(3, 6) = 96        objWorksheet.Cells(4, 1) = "atl-dc-03"    objWorksheet.Cells(4, 2) = 78    objWorksheet.Cells(4, 3) = 76    objWorksheet.Cells(4, 4) = 95    objWorksheet.Cells(4, 5) = 90    objWorksheet.Cells(4, 6) = 91        Set objRange = objWorksheet.UsedRange    objRange.Select        Set colCharts = objExcel.Charts    colCharts.Add()        Set objChart = colCharts(1)    objChart.Activate        objChart.ChartType = 65        objChart.PlotArea.Fill.PresetGradient 1, 1, 7        objChart.SeriesCollection(1).Border.Weight = -4138    objChart.SeriesCollection(2).Border.Weight = -4138    objChart.SeriesCollection(3).Border.Weight = -4138        objChart.SeriesCollection(1).Border.ColorIndex = 2

Page 19: Draw A Horisontal Line In Excel Chart With Only One Column

    objChart.SeriesCollection(1).MarkerBackgroundColorIndex = 2        objChart.SeriesCollection(2).MarkerForegroundColorIndex = 1    objChart.SeriesCollection(3).MarkerForegroundColorIndex = 1        objChart.HasTitle = True    objChart.ChartTitle.Text = "Attempted Logons"    objChart.ChartTitle.Font.Size = 18        objChart.ChartArea.Fill.Visible = True    objChart.ChartArea.Fill.PresetTextured 15        objChart.ChartArea.Border.LineStyle = 1        objChart.HasLegend = True    objChart.Legend.Shadow = True

BY THE WAY, IS THERE ANYBODY ELSE THAT KNOW ANY REFERENCE OR BOOKS TO FOLLOW AND HELP ME OUT WITH THIS KIND OF PROGRAM LINE WITH CHARTS?

thanks

Edited by - bruno_lg on 8/4/2008 4:31:51 AM

Excel Chart &gt; Help Hi, anyone could help me..

Is there a way to plot the chart in excel with a strin value?for example:

Item QuantityApple MediumBooks LowAssets HighOther Insufficient

I need to show this detail on a chart.

Thanks in advance.

Excel Pie-Chart Hello guys!

Page 20: Draw A Horisontal Line In Excel Chart With Only One Column

I would like to know how i can create pie-charts using Excel macro? Any pointers, tips and starting points? Or any tutorials to recommend? Thanks a real lot..

Take care

Cheers,Adrian

Seek and you shall find...

Excel Chart Hi,I want to add one Chart in an Excel Workbook.I can do that by using the following code.But the code adds the Chart as First Sheet in the workbook.I want to add the chart as last sheet.What should i do?

Code:

dim xl as objectdim xlBook1 as objectdim xlChart1 as Excel.Chart

set xl=CreateObject("Excel.Application")set xlBook1=xl.workbooks.open(filename:="C:Temp.xls")Set xlChart1 = xlBook1.Charts.AddxlChart1.Name = "Time

Thanks in advance.

Excel Chart With VB Hi guys,

I'd like my VB application to generate a chart automatically by clicking on a button. I have a table of authors. The code below shows what i've done so far:

Code:

Dim ApExcel As Excel.ApplicationDim xlApp As Excel.ApplicationSet xlApp = New Excel.ApplicationDim xlWkb As Excel.WorkbookSet xlWkb = xlApp.Workbooks.Add

Page 21: Draw A Horisontal Line In Excel Chart With Only One Column

Dim xlSht As Excel.WorksheetSet xlSht = xlWkb.Worksheets(1)Dim xlChart As Excel.ChartxlSht.Visible = TrueDim x, y As Integer

For x = 1 To frmRod.lstPaper.ListCountxlApp.Cells(x, 1).Formula = frmRod.lstPaper.List(x - 1)Next x

For y = 1 To frmRod.lstCount.ListCountxlApp.Cells(y, 2).Formula = frmRod.lstCount.List(y - 1)Next y

xlApp.Visible = TrueSet xlChart = xlWkb.Charts.AddxlChart.Visible = TruexlChart.ChartType = xl3DColumn

xlChart.SetSourceData xlSht.Range("A1:A" & frmRod.lstPaper.ListCount), xlColumnsxlChart.SetSourceData xlSht.Range("B1:B" & frmRod.lstCount.ListCount), xlColumnsxlChart.Visible = xlSheetVisiblexlChart.ActivatexlChart.HasTitle = TruexlChart.ChartTitle.Text = "CONFERENCE MANAGER"xlChart.HasLegend = True

xlChart.ChartArea.Font.Size = 15xlChart.ChartArea.Font.Color = vbBlue

Dim xla As AxisSet xla = xlChart.Axes(xlCategory)xla.HasTitle = Truexla.AxisTitle.Text = "Country"Set xla = xlChart.Axes(xlSeriesAxis)xla.HasTitle = TrueSet xla = xlChart.Axes(xlValue)xla.HasTitle = True

This code runs with error messages but shows a chart. On the category axis, it's not showing the names of the countries as expected but a series of integers from 1 to 7. These were supposed to be 7 countries. Without the last 8 lines, the code still works. The main problem is that i want the country names to be shown on the category axis instead of 1 - 7. The country names are displayes in the range A1 : A7 as shown with the following line of code:

Code:

Page 22: Draw A Horisontal Line In Excel Chart With Only One Column

Chart.SetSourceData xlSht.Range("A1:A" & frmRod.lstPaper.ListCount), xlColumns

and their occurrences are displayed in the range B1 : B7 as shown with the following line of code:

Code:

Chart.SetSourceData xlSht.Range("B1:B" & frmRod.lstCount.ListCount), xlColumns

Sorry about this long code, please help me.Just to remind you again, the main problem is that i want the country names to be shown on the category axis instead of 1 - 7.

Thanks a lot in advance.

Rich.

Excel Chart In VB Hello All.I created "xl3DColumnClustered" Chart in VB using Excel Macro (VB Automation), whom data was taken from the access DB.

In the graph i want to see the "LEGEND"

ActiveChart.HasLegend = True

and i want to give names to series in the "LEGEND"

1 Do While Not result.EOF2 ActiveChart.SeriesCollection(i).name _= result.Fields("Name") 'take "name" from DB 'put it in series name3 i = i + 14 result.MoveNext5 Loop

but line 2 works just one time, and in the second ertrance to this line it gives " Run time error 1004. "Does somebody know what is the problem?

Thanx a lot.Ilya.

Excel Chart i am using VB6 for my project.i need to create charts in it. VB chart is not enough. how can i automate the EXCEL chart from VB.please send the code if possible.

Page 23: Draw A Horisontal Line In Excel Chart With Only One Column

regards,

naresh

Excel Chart Help Please... Hello everybody!I have a big problem here. I have already added in my form an excel chart. but i don't know how to manipulate it run time. I hope you can give me basic examples for me to be able to display a chart of which the data will be based by what the user wants to display. and plus the data that i will be displaying comes from a binary file that i have to be extracted. please help me! i've been researching and researching but can't find the exact method i want to. Thank you very much.

Excel Chart I have plenty of experience with exporting data to Excel, but I've never created a chart in excel from VB. What I want to do is display a small chart on the same sheet that I generate my data. Representing the data in cells there. Any places to point me for examples?

Excel Chart How can I reduce number of colors of Chart palette when I export GIF file ?Thanks.

Zoom Chart Excel Hi,

I am looking for a way to zoom in/out in an excel chart. I found a lot of posts. Has anyone actually made such a function and is willing to share it?

Usul

Excel Chart In VB Problem have used excel object to draw a chart in visual basic 6. i have defined the width and height of the chart area, so it works fine, but running in other company computer this chart area has been increased so the half of it has been displayed.Set oChart = WS2.ChartObjects.Add(0, 0, 505, 50).ChartoChart.ChartType = Excel.XlChartType.xlLineoChart.SetSourceData (WS1.Range("A1").Resize(cNumRows, cNumCols))WS2.ChartObjects(1).Height = 130but on some computer it doesn't obey this size so it sounds that create a larger chart area than it is defined.

can anybody give me an idea on what's going on there?