private: // User declarations
Variant my_Word;
Variant my_Excel;
TForm1 *Form1;
PropertySet Connect_Word("Visible");
PropertySet Connect_Excel("Visible");
Procedure Disconnect_Word("Quit");
Procedure Disconnect_Excel("Quit");
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
try
{
my_Word=Variant::CreateObject("Word.Application");
Connect_Word<<true;
my_Word.Exec(Connect_Word);
}
catch(...)
{
ShowMessage("Word is not installed");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
try
{
my_Excel=Variant::CreateObject("Excel.Application");
Connect_Excel<<true;
my_Excel.Exec(Connect_Excel);
}
catch(...)
{
ShowMessage("Excel is not installed");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
try
{
Disconnect_Word<<false;
my_Word.Exec(Disconnect_Word);
my_Word=Unassigned;
}
catch(...)
{
ShowMessage("Word is not installed");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
try
{
Disconnect_Excel<<false;
my_Excel.Exec(Disconnect_Excel);
my_Excel=Unassigned;
}
catch(...)
{
ShowMessage("Excell is not installed");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Label1->Caption=DateToStr(Date());
Label2->Caption = TimeToStr(Time());
}
Brak komentarzy:
Prześlij komentarz