środa, 7 lutego 2018

Information about Excel (GetActiveObject,OleProprtyGet - C++ Builder)




void __fastcall TForm1::Button1Click(TObject *Sender)
{
 Variant Info;
 UnicodeString e_openFile,e_Value,e_Address,e_activeSheet,e_Object;
 Info=Null;
 e_Object="Excel.Application";
 try
 {
try
{
Variant Info=Variant::GetActiveObject(e_Object);
e_openFile=Info.OlePropertyGet("ActiveWorkbook").OlePropertyGet("Name");
Edit1->Text=e_openFile;
e_activeSheet=Info.OlePropertyGet("ActiveSheet").OlePropertyGet("Name");
Edit2->Text=e_activeSheet;
e_Value=Info.OlePropertyGet("ActiveCell").OlePropertyGet("Value");
Edit3->Text=e_Value;
e_Address=Info.OlePropertyGet("ActiveCell").OlePropertyGet("Address");
Edit4->Text=e_Address;

}
catch(EOleSysError* text_Error)
{
Edit1->Text="Error: "+text_Error->Message;
Edit2->Text=Edit1->Text;
Edit3->Text=Edit1->Text;
Edit4->Text=Edit1->Text;
}
catch(...)
{
  Edit1->Text="Fatal error";
  Edit2->Text=Edit1->Text;
  Edit3->Text=Edit1->Text;
  Edit4->Text=Edit1->Text;
}
}
__finally
{
Info=Unassigned;
}


}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
 Close();
}

Brak komentarzy:

Prześlij komentarz