Excel 2010 automation constants not working in Delphi XE7 -


i trying convert program delphi 2010 delphi xe7 (32 bit/windows vcl). code used work in d2010 automated excel via late binding ole gives exception "unable set window state property of application class" in delphi xe7, when app maximized or minimized.

i getting constants xlmaximized , xlminimized excelxp unit has these constants: xlmaximized = $ffffefd7; xlminimized = $ffffefd4;

however, if use simple constant values -4137 , -4140 program work ok. realize must doing simple wrong.

below sample code illustrates problem. tested , works in delphi 2010, not in delphi xe7. suppose must how constants handled in newer versions(?) can point me in right direction? in advance!

//xla global variable of type olevariant; //program uses comobj , excelxp unit  //this proc runs or connects excel  procedure tform3.runexcelclick(sender: tobject);  begin   try     xla := getactiveoleobject('excel.application');   except     try       xla := createoleobject('excel.application');     except       on e: exception         begin           showmessage(e.message);         end;     end;     xla.visible := true;   end; end;   procedure tform3.maxexcelclick(sender: tobject); begin    //this code gives exception    xla.windowstate := xlmaximized;  //-4137;  works ok if use number end;  procedure tform3.minexcelclick(sender: tobject); begin    //or this.  exceptions    xla.windowstate := xlminimized ; //-4140; works ok if use number end; 

it's data type issue. $ffffefd7 signed 32 bit integer -4137 (and excel expects). according quick goolge search delphi longint signed 32 bit int, maybe there type casting going on...

according op's own research, setting

system.variants.dispatchunsignedassigned := true; 

solves it.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -