Welcome, Guest
Guest Settings
Help

Thread: Having to typecast excel constants


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Apr 5, 2017 8:27 AM Last Post By: richard skinner Threads: [ Previous | Next ]
richard skinner

Posts: 3
Registered: 12/18/00
Having to typecast excel constants  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 5, 2017 8:02 AM
I'm using late binding however I include the ExcelXP unit for all the constants.

I'm moving code from Delphi XE to Deliphi Tokyo and all my Excel COM calls are failing unless I typecast the excel constants as a integer.
Is there a compiler setting I'm missing? I sure hate to typecast all these calls. I never had to typecast any of the XL Constants before, not sure why I have to now?

Example:
RPMChart := WB.Sheets.Add(null, null, 1, integer(xlChart));
RPMChart.name := 'RPM';
RPMChart.SetSourceData(DataSheet.Range['H2:H91'], integer(xlcolumns));
RPMChart.ChartType := integer(xlLine);

RPMChart.Axes(xlValue).select;
RPMChart.Axes(xlValue).MinimumScale := 500;
RPMChart.Axes(xlValue).MaximumScale := 1900;
RPMChart.Axes(xlValue).MinorUnitIsAuto := True;
RPMChart.Axes(xlValue).MajorUnitIsAuto := True;
RPMChart.Axes(xlValue).Crosses := integer(xlAutomatic);
RPMChart.Axes(xlValue).ReversePlotOrder := False;
RPMChart.Axes(xlValue).ScaleType := integer(xlLinear);
RPMChart.Axes(xlValue).DisplayUnit := integer(xlNone);
RPMChart.SeriesCollection[1].select;
XlApp.Selection.Border.Weight := integer(xlMedium);
XlApp.Selection.Border.LineStyle := integer(xlContinuous);

Edited by: richard skinner on Apr 5, 2017 8:03 AM

Remy Lebeau (Te...


Posts: 7,926
Registered: 12/23/01
Re: Having to typecast excel constants [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 5, 2017 8:17 AM   in response to: richard skinner in response to: richard skinner
Richard wrote:

I'm moving code from Delphi XE to Deliphi Tokyo and all my Excel COM
calls are failing unless I typecast the excel constants as a integer.

Failing how exactly? What do the actual errors say? Are they compile-time
errors, or runtime errors?

Is there a compiler setting I'm missing? I sure hate to typecast all
these calls. I never had to typecast any of the XL Constants before,
not sure why I have to now?

How are the constants declared to begin with?

--
Remy Lebeau (TeamB)


---
This email has been checked for viruses by AVG.
http://www.avg.com

richard skinner

Posts: 3
Registered: 12/18/00
Re: Having to typecast excel constants  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 5, 2017 8:27 AM   in response to: richard skinner in response to: richard skinner
Answer is here......
[http://docwiki.embarcadero.com/Libraries/XE7/en/System.Variants.DispatchUnsignedAsSigned]


richard skinner wrote:
I'm using late binding however I include the ExcelXP unit for all the constants.

I'm moving code from Delphi XE to Deliphi Tokyo and all my Excel COM calls are failing unless I typecast the excel constants as a integer.
Is there a compiler setting I'm missing? I sure hate to typecast all these calls. I never had to typecast any of the XL Constants before, not sure why I have to now?

Example:
RPMChart := WB.Sheets.Add(null, null, 1, integer(xlChart));
RPMChart.name := 'RPM';
RPMChart.SetSourceData(DataSheet.Range['H2:H91'], integer(xlcolumns));
RPMChart.ChartType := integer(xlLine);

RPMChart.Axes(xlValue).select;
RPMChart.Axes(xlValue).MinimumScale := 500;
RPMChart.Axes(xlValue).MaximumScale := 1900;
RPMChart.Axes(xlValue).MinorUnitIsAuto := True;
RPMChart.Axes(xlValue).MajorUnitIsAuto := True;
RPMChart.Axes(xlValue).Crosses := integer(xlAutomatic);
RPMChart.Axes(xlValue).ReversePlotOrder := False;
RPMChart.Axes(xlValue).ScaleType := integer(xlLinear);
RPMChart.Axes(xlValue).DisplayUnit := integer(xlNone);
RPMChart.SeriesCollection[1].select;
XlApp.Selection.Border.Weight := integer(xlMedium);
XlApp.Selection.Border.LineStyle := integer(xlContinuous);

Edited by: richard skinner on Apr 5, 2017 8:03 AM

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02