#include
# pragma hdrstop
# include "Unit1. H"
# define PG OlePropertyGet
# define PS OlePropertySet
# define FN OleFunction
# define PR OleProcedure
# include "Comobj. HPP
"//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma package (smart_init)
# pragma resource "*. DFM
"TForm1 * Form1;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
__fastcall TForm1: : TForm1 (TComponent * Owner)
: TForm (the Owner)
{
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{
The Variant Ex, Wb, St.
Try
{
The Ex=the Variant: : CreateObject ((WideString) (L "Excel. Application"));
}
The catch (... )
{
ShowMessage (" Excel operation error, please make sure to install Office ");
return;
}
Ex. PS (WideString "Visible" (L), false);
Ex. PG (WideString "WorkBooks") (L), PR (WideString "Open" (L), WideString (L "c: \ \ 1. XLSX"));
Wb=Ex. PG (WideString (L "ActiveWorkBook"));
St=Wb. PG (WideString (L "ActiveSheet"));
Wb. PR (WideString "SaveAs" (L), WideString (L "c: \ \ 2. XLSX"));//save
Wb. PR (WideString (L "Close"));//close
Ex. FN (WideString (L "Quit"));//out
The Ex=Unassigned;
Wb=Unassigned;
St=Unassigned;
MessageBox (NULL, "after running Excel!!!!!! ", "prompt", MB_OK);
}
When the program execution problem: as long as set to false the Ex. PS (WideString "Visible" (L), false);
Program finally bound to error
But as long as the Ex. PS (WideString "Visible" (L), false); The false to true here wouldn't out the above error!
Please help to give directions, the novice my novice! Thank you very much!
(Windows 7 64 - bit + EXECL2007 + BCB2010)
CodePudding user response:
Strives for the leaders to give directions! Thank you for