ما رأيكم فى هذا الكود
كود :
procedure TForm1.InsertLines(LineNum : Integer);
var
iCount : Integer;
begin
for iCount := 1 to LineNum do
wrdApp.Selection.TypeParagraph;
end;
procedure TForm1.FillRow(Doc : Variant; Row : Integer;
Text1,Text2,Text3,Text4 : String);
begin
Doc.Tables.Item(1).Cell(Row,1).Range.InsertAfter(Text1);
Doc.Tables.Item(1).Cell(Row,2).Range.InsertAfter(Text2);
end;
procedure TForm1.CreateMailMergeDataFile;
var
wrdDataDoc : Variant;
iCount : Integer;
begin
// Create a data source at C:\DataDoc.doc containing the field data
wrdDoc.MailMerge.CreateDataSource('C:\DataDoc.doc',,,'FirstName, LastName,' +
' Address, CityStateZip');
// Open the file to insert data
wrdDataDoc := wrdApp.Documents.Open('C:\DataDoc.doc');
for iCount := 1 to 2 do
wrdDataDoc.Tables.Item(1).Rows.Add;
// Fill in the data
FillRow(wrdDataDoc, 2, 'Steve', 'DeBroux',
'4567 Main Street', 'Buffalo NY 98052');
FillRow(wrdDataDoc, 3, 'Jan', 'Miksovsky',
'1234 5th Street', 'Charlotte NC 98765');
FillRow(wrdDataDoc, 4, 'Brian', 'Valentine',
'12348 78th Street Apt. 214', 'Lubbock TX 25874');
// Save and close the file
wrdDataDoc.Save;
wrdDataDoc.Close(False);
end;[/CODE
procedure TForm1.Button3Click(Sender: TObject);
var
WordApplication, WordDocument, wrdSelection, wrdMailMerge, wrdMergeFields ,wrdDataDoc: Variant;
begin
WordApplication := CreateOleObject('Word.Application');
WordApplication.Visible := True;
// Create a new document
WordDocument := WordApplication.Documents.Add();
WordDocument.Select;
wrdSelection := WordApplication.Selection;
wrdMailMerge := WordDocument.MailMerge;
WordApplication.Selection.TypeText(' ÈÓã Çááå ÇáÑÍãä ÇáÑÍíã');
WordApplication.Selection.TypeText(' ');
WordApplication.Selection.TypeText('hhhhh');
// Insert a new table with 2 rows and 2 columns
WordDocument.Tables.Add(wrdSelection.Range,2,2);
WordDocument.Tables.Item(1).Columns.Item(1).SetWidth(170,wdAdjustNone);
WordDocument.Tables.Item(1).Columns.Item(2).SetWidth(170,wdAdjustNone);
WordDocument.Tables.Item(1).Rows.Item(1).Cells
.Shading.BackgroundPatternColorIndex := wdGray25;
// BOLD the first row
WordDocument.Tables.Item(1).Rows.Item(1).Range.Bold := True;
// Center the text in Cell (1,1)
WordDocument.Tables.Item(1).Cell(1,1).Range.Paragraphs.Alignment :=
wdAlignParagraphCenter;
// Fill each row of the table with data
FillRow(WordDocument, 1, 'ãßÊÈ ãÍãÏ', 'Class Name', 'Class Time',
'Instructor');
FillRow(WordDocument, 2, 'EE220', 'Introduction to Electronics II',
'1:00-2:00 M,W,F', 'Dr. Jensen');
WordDocument.SaveAs(FileName := 'C:\n.Doc',
AddToRecentFiles := False);
end;
