Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

graph excel

Status
Not open for further replies.

fluppe689

Programmer
Jul 11, 2008
75
BE
Dear Experts

I have exported a cursor to excel with the following result

UK 683384,99
SLOVAKIA 58911,24
SWISS 3296,00
SINGAPORE 43768,57
SENEGAL 4411,50
POLAND 6264,53
NEDERLAND 53529,29
INDIA 19040,34
GERMANY 180,00
FUERTEVENTURA 31259,70
FRANCE 228053,50
CZECH REPUBLIC 53792,14
CABO VERDE 2033,77
BELGIUM 792008,35
AUSTRIA 15033,93


so far no problem

what is want to become is to make 3D CHART with the result of that table
I never did this so any help would be much appriciated

Filip Merlier






 
Select the columns, then insert a chart and choose a 3d chart type.

I did just that with macro recording:
Code:
    Range("A1:B15").Select
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xl3DColumnClustered
    ActiveChart.SetSourceData Source:=Range("testdata!$A$1:$B$15")
    ActiveSheet.Shapes("Diagram 1").ScaleWidth 1.68125, msoFalse, _
        msoScaleFromTopLeft
    ActiveSheet.Shapes("Diagram 1").ScaleHeight 1.7135418489, msoFalse, _
        msoScaleFromTopLeft

The Range of course depends on your data and how you scale and position the final graph , too. So the core code really just is adding a chart, settings it's type and source cells.

Bye, Olaf.
 
The best way (in my personal opinion) of determining the VFP Automation code necessary to get things done in Excel is to first not use VFP At All.

* Have your data where you want it in an Excel file.
* Open Excel and begin recording a Macro.
* Do what you want to do.
* When done, stop recording the Macro.
* Then examine the Macro code (it will be in VBA but generally it can be fairly readily converted to VFP Automation code).

Olaf has shown you his Macro code above. If that works for you, great.
If not, record your own Macro.

Then migrate that code into your VFP Automation code.

Good Luck,
JRB-Bldr
 
Some more general advice on how VBA specifics translate to VFP.

1. When you create an EXCEL.APPLICATION object in the VFP command window you can make use of Intellisense to explore the object model life, sometimes that's easier to do than readding docs, so after doing o = CreateObjject("Excel.Application") you pretty much can explore all, which is available to you in Excel automation.

You'll easily identify ActiveSheet, ActiveChart, ActiveWorkbook etc. are root properties of o, which is why they are root objects available to VBA code, too, just with no o. in front, as VBA is inside the same document and inside the Excel Application itself. Something like a RANGE is more buried, though, than the VBA code suggests, the Range method returning a range object is part of the ActiveSheet. After you call Range().Select there is o.Selection and so on and so forth.

Another thing to learn is named parameters and VBA call conventions, eg in my recorded sample code you see the line "ActiveChart.SetSourceData Source:=Range("testdata!$A$1:$B$15")"

Source here is a named paraameter of the SetSourceData Method of the Chart object. It's the first parameter in the method definition SetSourceData(Source, PlotBy) and so this translates to a call of o.ActiveChart.SetSourceData(o.ActiveSheet.Range("A1:B15")) for example, the parameter put into paranthesis. If Source would be the second parameter by the method definition this would translate to VFP code omitting the first parameter.

These are just two details, there are Hentzenwerke Books on Office Automation worth reading to get into more aspects of it.

Bye, Olaf.

 
Nice isn't it? An enumeration with just one item (1.) The "2." is missing before "Another thing"...

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top