Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

OLE Automation

chip645
Beginner
2,016 Views
I'm having a tough time "Talking" to Excel2000 via OLE.

Where can I find the "Magic Numbers" for the "Gallery" and "Format" arguments in the ChartWizard call? I'd dearly love to specify an "XYScatter" plot with lines and no markers...

Also, where can I look for documentation on the DFAUTO routines? I'm running "Digital" Visual Fortran Standard Edition 6.0.A and all I can find on the Compaq site are release notes talking about how all kinds of terrible problems with the DFAUTO routines have been fixed in later releases. Should I just hang it up?

Given that "range" is one of the arguments to the AUTOSETPROPERTY function, I would have assumed that I could use it to load a "vertical" (column) range in Excel- but I never had any luck. What am I missing?
0 Kudos
7 Replies
Intel_C_Intel
Employee
2,016 Views
As far as I understand your question you're looking for the values within the statement like this one:

xpression.ChartWizard (Source, Gallery, Format, PlotBy, CategoryLabels, SeriesLabels, HasLegend, Title, CategoryTitle, ValueTitle, ExtraTitle)

where both Gallery of XlChartType and Format are optional variants. As Excel is, here, Automation Server all info about its methods/interfaces should be in its documentation.
Other option to determine all the constants used by Excel is to read its type library (you can do it in two ways: use OleView application (within VF or that which ships with the MSDK) or use Delphi (for example) and import type library (if you have it installed).

Artur
0 Kudos
isn-removed200637
2,016 Views
As a complete beginner myself, I can recommend trying the AUTODICE example in the Samples...Advanced...COM folder.
Although the code says that EXCEL97 must be present, I found the way to adapt it to my version of EXCEL in Office 2000.
The best way to learn is to select Tools..fortran module wizard, then, in the first dialog box select the 'Type library containing automation information' button, enter a name for the module that will be created (e.g. EXCEL2000) and press 'Next'.
In the next dialog box, browse in the 'Type information filename' list and look for your system's version of the EXCEL type library (mine was EXCEL9.OLB in Program filesOffice..), select it into the list box and then press the 'show components' button.
You are now presented with an enormous list of components that you can select from.
To make a selection, I took my lead from the pseudocode given in AUTODICE.F90, see here
	! Here is a sketch of the code below in pseudocode...
	!
	!	workbooks = excelapp.GetWorkbooks()
	!	workbook = workbooks.Open(spreadsheet)
	!	worksheet = workbook.GetActiveSheet
	!	range = worksheet.GetRange("A1", "L1")
	!	range.Select()
	!	charts = workbook.GetCharts()
	!	chart = charts.Add()
	!	chart.ChartWizard(gallery=chartType, title=title, categoryTitle=title, valueTitle=title)
	!	valueAxis = chart.Axes(type=xlValue, axisGroup=xlPrimary)
	!   valueAxis.MaximumScale(loopcount/5)

SO I selected from the top of the list (note the underline characters at the start) _application, _chart, _global, _oleobject, _workbook, _worksheet.
I also selected 'Range', 'workbooks', 'worksheets' from further down the list, and from the enumerators list I selected XLAxisgroup and XLAxistype (these were selected because they figure at the start of the module EXCEL97.F90 included with the example).

The only changes I had to make were using Excel.application.9 as the program ID in the call to COMCREATEOBJECT in Autodice.f90 and to change the interface generated for Range_Select in the automatically-generated module EXCEL2000.F90 from FUNCTION to SUBROUTINE (using the template in EXCEL97A.F90), because Range_Select is CALLed in Autodice.F90, and the first attempt at linking failed because the subroutine with two integer arguments (8 bytes) couldn't be found for the simple reason that only a FUNCTION of that name was defined.

I then edited USE EXCEL97A to become USE EXCEL2000 in AUtodice.F90 and compiled the two modules ADOBJS.F90 and EXCEL2000, then compiled Autodice.F90 and linked. There were a few warnings about superfluous DLLEXPORT compiler directives but after the changes made above, all went well.
The example runs OK and produces a nice chart in EXCEL, which remains open after the program exits. I suggest you then play with the code in Autodice.F90 to see how you can affect the chart etc. Hope this helps
0 Kudos
chip645
Beginner
2,016 Views
Yeah, I went down the autodice path just ahead of you and had the same adventures.

I wasn't so bold as to prune the interface list a priori- and I wound up with a hugefunction that takes a half hour to compile :(

Are you saying that you changed the interfacedefinition of "Range_select" and it worked?!

What temerity! I changed the autodice reference to a function (which took some doing given the convoluted "type" environment) and thatworked fine, too.

My question had to do with the arbitrary (AKA "Magic") numbers that you pass to chartwizard to specify the chart type. A combination of trial and error and browsing through scattered hints turned up that either "7" or "-4169" (appropriately massaged) will generate the "XY scatter" plot I'm looking for- but I still haven't found a value for "format" that yields "lines with no points"-- which was what I was looking for.

Here are my trial-and-error "format" results:

! vInt3%VU%LONG_VAL = 1 ! w/points
! vInt3%VU%LONG_VAL = 2 ! w/points w/lines
! vInt3%VU%LONG_VAL = 3 ! w/points
! vInt3%VU%LONG_VAL = 4 ! semi-log
! vInt3%VU%LONG_VAL = 5 ! log-log
vInt3%VU%LONG_VAL = 6 ! smooth w/o points
! vInt3%VU%LONG_VAL = 7 ! N/A (aborts)
! vInt3%VU%LONG_VAL = 8 ! N/A (aborts)
! vInt3%VU%LONG_VAL = 9 ! N/A (aborts)

I've forgotten what "0" did- but I think it was the same as "1"
0 Kudos
selahattin
Beginner
2,016 Views
First of all, your notes to create Excel2000 is very clear and useful for beginners .
But, when compiling the Excel2000 I get the fatal error message: Internal Compiler Error C0000005. My version is CVF6.1.
Is there anybody to give an idea for this problem?
Where can I find the description of Internal Compiler Error Messages?
0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,016 Views
Attached is MS KB Article Q189265; search on MSDN for any of xl* constants should yield some additional info.
0 Kudos
Steven_L_Intel1
Employee
2,016 Views
There is no "list of internal compiler error messages" - an internal compiler error is always a compiler bug. If you can reproduce the problem in a current version (6.6A), let us know at vf-support@compaq.com.

Steve
0 Kudos
csabagabor
Beginner
2,016 Views

Dear Unknown, who could revitalizes the autodice sample program, to the excel2000. I've tested this program and I find that it has never worked properly. The chart appears only once and next time you call it the diagram will not change, in spite of the fact, that the values of the chart bars is calculated as random numbers, and on the black background on the notice appears "Unable to get Range object"




Gbor CSABA
BUDAPEST
0 Kudos
Reply