*!* Below example is for Graph8. (Nearly same as Excel charting) *!* If you cannot download wc0993.exe from microsoft site or UT files section *!* xlConstants can be found by : *!* -Open Excel *!* -Select tools\macro\VB editor *!* -Press F2 to bring up "Object browser" *!* -Find needed xlConstant type ie:xlChartType *!* -On right window click needed Constant ie: xl3DArea *!* -Below the window constant value is displayed *!* cetin@imst.deu.edu.tr *** set the LOCALEID to English nlLocaleId=sys(3004) && Save local id =sys(3006,1033) && We will be sending instructions in English * Part of xlChartType constants #Define xl3DArea -4098 #Define xl3DColumn -4100 #Define xl3DLine -4101 #Define xl3DPie -4102 #Define xlArea 1 #Define xlBubble3DEffect 87 #Define xlLine 4 #Define xlPie 5 #Define xlRadar -4151 #Define xlSurface 83 #Define TAB CHR(9) #Define CRLF CHR(13)+CHR(10) Create cursor test (degree i, sine n(8,4) NULL, cosine n(8,4)) For ix = 1 to 90 Insert into test ; values ; (ix,cos(ix)*ix,sin(ix)*ix) Endfor 45 Scan next 30 && Nullify 30 degrees Replace sine with .null. && Nullify some values to see effect Endscan Wait window nowait "Filling cell values..." MCGDATA = "" nCols = fcount() For ix = 1 to nCols MCGDATA = MCGDATA + iif(empty(MCGDATA),"",TAB)+field(ix) Endfor MCGDATA = MCGDATA + CRLF Scan For ix = 1 to nCols MCGDATA = MCGDATA + iif(ix=1,"",TAB)+nvl(str(evaluate(field(ix))),"") Endfor MCGDATA = MCGDATA + CRLF Endscan * Data prepare * Create cursor testgen (graphtest g) Append blank Append general graphtest class "MSGraph.Chart" data MCGDATA Create report testgraph from testgen Messagebox("Now you'll see a report designer window."+chr(13)+; "Pls add an OLEBoundControl and size big enough." ; +chr(13)+"Use [graphtest] as fieldname") Modi report testgraph *** * Now we have Graph object in gen field. (Graph8) * Play with it oForm = createobject("Form") With oForm .height = 400 .width = 600 .show .closable = .f. .addobject("myGraph","OleBoundControl") .addobject("myQuit1","myQuit") .addobject("myChanger1","myDataChanger") .addobject("myChanger2","myTypeChanger") .addobject("myPaster","myWordPaster") .addobject("myReport1","myReport") With .myGraph .height = oForm.height - 20 .width = oForm.width .left = 0 .top = 0 .ControlSource = "testgen.graphtest" Wait window nowait "Plotting..." .hastitle = .t. .haslegend = .t. .ChartTitle.caption = "This is chart title" .ChartType=xlLine .object.application.plotby = 2 #Define xlCategory 1 #Define xlValue 2 #Define xlSeriesAxis 3 With .Axes(xlCategory) .hastitle = .t. With .AxisTitle .Caption = "This is category title" .Font.Name = "Arial" .Font.Size = 10 .Font.Bold = .t. Endwith Endwith *!* With .Axes(xlSeriesAxis) *!* .hastitle = .T. *!* With .AxisTitle *!* .Caption = "This is SeriesAxis title" *!* .Font.Size = 8 *!* .Font.Bold = .f. *!* .Orientation = 90 && Show 90 degrees rotated *!* Endwith *!* Endwith With .Axes(xlValue) .hastitle = .T. With .AxisTitle .Caption = "This is Value title" .Font.Size = 10 .Font.Bold = .f. .Orientation = 90 && Show 90 degrees rotated - clockwise Endwith #Define xlCustom -4114 #Define xlMinimum 4 #Define xlMaximum 2 .Crosses = xlMinimum * .CrossesAt = nValue Endwith *!* #define xlThick 4 *!* #define xlDashDotDot 5 *!* with .SeriesCollection(1).Border *!* .Color = rgb(255,255,0) *!* .LineStyle = xlDashDotDot *!* .Weight = xlThick *!* endwith *!* .hasdatatable = .t. *!* .DataTable.HasBorderOutline = .T. *!* With .DataTable.font *!* .name = "Arial" *!* .size = 8 *!* Endwith Wait clear .ChartArea.copy() .visible=.T. Endwith .myQuit1.visible = .t. .myReport1.left = .myChanger2.left+.myChanger2.width + 5 .myReport1.visible = .t. .myChanger1.visible = .t. .myChanger2.visible = .t. .myPaster.visible = .t. Endwith **** Set the LocaleId to the previous value =sys(3006,val(nlLocaleId)) Read events Define class myquit as commandbutton Left=1 Top=0 AutoSize = .T. Caption="Close" Procedure click Release all Clear events Endproc Enddefine Define class myDataChanger as commandbutton Left=150 Top=0 AutoSize = .T. Caption="Change some data" Procedure click Wait window nowait "Changing cell values..." With thisform.myGraph .hasdatatable = .f. && Temporarily turn it off With .object.application.datasheet Select test Scan If isnull(sine) .Cells(recno()+1,2).Value = sin(recno())*recno() Endif Endscan Endwith * .hasdatatable = .t. Endwith Select testgen * Thisform.myGraph.doverb(-6) Wait clear Endproc Enddefine Define class myTypeChanger as commandbutton Left=300 Top=0 AutoSize = .T. Caption="Change Chart Type" Procedure click Thisform.myGraph.ChartType = xlBubble3DEffect Thisform.myGraph.doverb(-6) Endproc Enddefine Define class myWordPaster as commandbutton Left=490 Top=0 AutoSize = .T. Caption="Paste to Word" Procedure click * Paste chart in clipboard to a word doc Thisform.myGraph.ChartArea.copy() oWrd = createobject("Word.application") With oWrd .documents.add() With .activedocument #Define wdOrientLandscape 1 #Define wdOrientPortrait 0 .PageSetup.Orientation = wdOrientLandscape .content.paste && Paste chart Endwith .visible = .t. .Activate Endwith Endproc Enddefine Define class myreport as commandbutton Left=1 Top=0 AutoSize = .T. Caption="Report" Procedure click * warning !!! - Testgraph prepared manually containing gen field and sized Report form testgraph preview Endproc EnddefineCetin