Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SERVERS Tab in DELPHi

Status
Not open for further replies.

NuWood

Programmer
Mar 14, 2002
44
GB
Hi

Anyone ever made use of the SERVERS tab in DELPHI with Word, Excel, Outlook etc.

They look dead useful but I cannot find any info on the use of them. They appear to reveal the API to Office but I get errors when using some etc.


Any hints or pointers to documentation would be appreciated as I need to make my application talk to Outlook and use it as a Diary,ToDo meetings etc....


regards
Andrew
 
Hi,
This is a routine that exports some tables to Excel, creating a Tab for each table in the same file.
************************************************************
procedure TForm1.Save2XlsBtnClick(Sender: TObject);
var i,row,column, Tab:integer;
ExcelApplication1:TExcelApplication;
ExcelWorkbook1:TExcelWorkbook;
ExcelWorksheet1:TExcelWorksheet;
Temp_Worksheet: _WorkSheet;
Vuoto:OleVariant;
begin
SaveDialog1.DefaultExt:='xls';
If Not SaveDialog1.Execute
Then Exit;

ExcelApplication1:= TExcelApplication.Create(Self);
ExcelApplication1.Workbooks.Add(Null,0);
ExcelApplication1.Visible[0]:=True;
ExcelApplication1.Caption:='Import dati del '+DateTimeToStr(Now);

ExcelWorkbook1:=TExcelWorkbook.Create(Self);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1:=TExcelWorksheet.Create(Self);

Try
ExcelApplication1.ConnectKind:= ckRunningOrNew;

Try
ExcelApplication1.Connect;
Except
MessageDlg('Excel may not be installed',
mtError, [mbOk], 0);
Abort;
End;

For Tab := 0 To 7 Do
Begin

WrkTbl.Active:=False;
Case Tab of
0: WrkTbl.TableNAme:='Cusomers';
1: WrkTbl.TableNAme:='Orders';
2: WrkTbl.TableNAme:='Parts';
3: WrkTbl.TableNAme:='Prices';
4: WrkTbl.TableNAme:='Alternates';
5: WrkTbl.TableNAme:='Pictures';
6: WrkTbl.TableNAme:='Employee';
7: WrkTbl.TableNAme:='SomeTable';
End;
WrkTbl.Active:=True;
WrkTbl.First;


If Tab >= ExcelWorkbook1.WorkSheets.Count
Then Begin
Temp_Worksheet:=ExcelWorkbook1.WorkSheets.Add(EmptyParam,ExcelWorkbook1.WorkSheets[ExcelWorkbook1.WorkSheets.Count],EmptyParam,EmptyParam,0) as _WorkSheet;
ExcelWorkSheet1.ConnectTo(Temp_WorkSheet);
End
Else ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[Tab+1] as _Worksheet);

//Nome orecchietta = NomeTabella
ExcelWorksheet1.Name:=WrkTbl.TableNAme;

//NomeColonne
row:=1;
column:=1;
for i:=0 to WrkTbl.FieldCount-1 do
begin
ExcelWorksheet1.Cells.Item[row,column]:=WrkTbl.fields[ i].FieldName;
column:=column+1;
end;
row:=2;

While Not WrkTbl.Eof do
Begin
column:=1;
for i:=0 to WrkTbl.FieldCount-1 do
begin
ExcelWorksheet1.Cells.Item[row,column]:=WrkTbl.fields[ i].AsString;
column:=column+1;
end;
WrkTbl.Next;
row:=row+1;
End;
End;

//Foglio riassuntivo
Temp_Worksheet:=ExcelWorkbook1.WorkSheets.Add(ExcelWorkbook1.WorkSheets[1],EmptyParam,EmptyParam,EmptyParam,0) as _WorkSheet;
ExcelWorkSheet1.ConnectTo(Temp_WorkSheet);
//Nome orecchietta = Riassunto
ExcelWorksheet1.Name:='RIASSUNTO';
ExcelWorksheet1.Cells.Item[1,1]:='RIASSUNTO Import dati del '+DateTimeToStr(Now);
For i:=2 to LogMemo.Lines.Count-1 do
Begin
ExcelWorksheet1.Cells.Item[i,1]:=LogMemo.Lines[ i];
End;


ExcelWorkbook1.Close(True,SaveDialog1.Filename);
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
ExcelWorkbook1.Disconnect;

Finally
ExcelWorksheet1.Free;
ExcelWorkbook1.Free;
ExcelApplication1.Free;
End;
end;
************************************************************
Maybe this don't meet your needs, but I guess that can be usefull for many others.

Ciao,
Geppo Darkson.
 
Thanks to both of you.

I have done some more work and am fine with Word and Excel its Outlook thats giving me a Headache. By the way the Ecel example is very useful.

Does anyone have an example of creating a note in Outlook to get me on my way.

I get a Class not Registered if I attempt to use the NoteItem.


regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top