How to save excel document without dialog


2005-08-26 11:17:36 PM
cppbuilder43
Hi All,
I found some code on previous posts and I modified it to compile properly.
The problem is that I can't manage to save the document under the same name
without getting any prompts to save. I wonder if there is such a function.
Here is the code:
Any help appreciated.
Regards,
Nicolae
//*****************************
Excel_2k::RangePtr Cell;
// Configuring your Control
ExcelApplication1->AutoConnect = false;
ExcelApplication1->ConnectKind = ckNewInstance;
ExcelWorkbook1->AutoConnect = false;
ExcelWorkbook1->ConnectKind = ckAttachToInterface;
ExcelWorksheet1->AutoConnect = false;
ExcelWorksheet1->ConnectKind = ckAttachToInterface;
// Open Excel
ExcelApplication1->Workbooks->Open(StringToOleStr("C:\\Test1.xls"));
// Must put Full Path
ExcelApplication1->set_Visible(LOCALE_SYSTEM_DEFAULT,false);
// ----------- Putting values
Cell = ExcelApplication1->get_Range((TVariant)"A20", (TVariant)"B25");
Cell->set_Value(TVariant("Application.Cells"));
ExcelWorksheet1->ConnectTo(ExcelApplication1->Worksheets->get_Item((TVariant)1));
Cell=ExcelWorksheet1->get_Range((TVariant)"H20", (TVariant)"H24"); //
Cell->set_Value(TVariant("234"));
ExcelWorkbook1->ConnectTo(ExcelApplication1->Workbooks->get_Item(TVariant(1)));
ExcelWorksheet1->ConnectTo(ExcelWorkbook1->Sheets->get_Item((TVariant)1));
Cell=ExcelWorksheet1->get_Range((TVariant)"F3", (TVariant)"G10"); //
Cell->set_Value(TVariant("Workbooks.Workseet.Range"));
Cell=ExcelWorksheet1->get_Range((TVariant)"B8", (TVariant)"C10"); //
Cell->set_Value(TVariant("123"));
// ------------ Geting one Value
Cell=ExcelWorksheet1->get_Range((TVariant)"A5", (TVariant)"A5"); //
Edit2->Text=OleVariant(Cell->get_Value());
// ------------ Getting Range of Values
Cell=ExcelWorksheet1->get_Range((TVariant)"A5", (TVariant)"B9"); //
OleVariant mv;
mv=OleVariant(Cell->get_Value());
if(mv.IsArray()){ // confirma se e array
Edit1->Text=mv.ArrayDimCount();
Memo1->Lines->Append(mv.GetElement(1,1));
Memo1->Lines->Append(mv.GetElement(1,2));
Memo1->Lines->Append(mv.GetElement(2,1));
Memo1->Lines->Append(mv.GetElement(2,2));
}
// Close and Save your Work
ExcelWorkbook1->Close((TVariant)false);
// Closing the Excel
ExcelApplication1->Quit();