ارسال صورة سطح المكتب لملف وورد من دلفي
#4
مثال للتعامل مع MS Word من خلال OLE
خمس مكونات TEdit، مكون TRadioGroup وTComboBox وTButton للتشغيل:
PHP كود :
uses
  ComObj
;

procedure TForm1.Button1Click(Sender: TObject);
var
  
Word: OLEVariant;
begin
  
try
    
Word := CreateOleObject('Word.Application');
  
except
    ShowMessage
('Cannot start Word !');
    Exit;
  
end;
  
// Show Word
  
Word.Visible := True;
  
// Add a new Document
  
Word.Documents.Add;
  if 
Word.ActiveWindow.View.SplitSpecial <> 0 then
    Word
.ActiveWindow.Panes[2].Close;
  if (
Word.ActiveWindow.ActivePane.View.type = 1) or
    (
Word.ActiveWindow.ActivePane.View.type = 2) or
    (
Word.ActiveWindow.ActivePane.View.type = 5) then
    Word
.ActiveWindow.ActivePane.View.type := 3;
  
Word.ActiveWindow.ActivePane.View.SeekView := 9;

  
Word.Selection.Font.Name     := 'Times New Roman';
  
Word.Selection.Font.Size     := 12;
  
Word.Selection.Font.Bold     := True;
  
Word.Selection.ParagraphFormat.Alignment := 1;
  
Word.Selection.TypeText(Text :=
    
'Tutorial Delphi4Arab - Automation MS Word');

  if 
Word.Selection.HeaderFooter.IsHeader = True then
    Word
.ActiveWindow.ActivePane.View.SeekView := 10
  
else
    
Word.ActiveWindow.ActivePane.View.SeekView := 9;
  
Word.Selection.TypeText(Text :=
    
'Automation MS Word - Kachwahed for Delphi4arab.com');
  
Word.ActiveWindow.ActivePane.View.SeekView := 0;
  
Word.Selection.TypeText(Text := Edit2.Text + ' ' + edit1.Text);
  
Word.Selection.TypeParagraph;
  
Word.Selection.TypeText(Text := edit3.Text);
  
Word.Selection.TypeParagraph;
  
Word.Selection.TypeParagraph;
  
Word.Selection.Font.Name := 'Times New Roman';
  
Word.Selection.Font.Size := 12;
  
Word.Selection.Font.Bold := True;

  
Word.Selection.TypeText(Text := edit4.Text + ' ' + edit5.Text);
  
Word.Selection.TypeParagraph;
  
Word.Selection.TypeParagraph;
  
Word.Selection.TypeParagraph;
  
Word.Selection.TypeParagraph;
  
Word.Selection.Font.Name     := 'Arial';
  
Word.Selection.Font.Size     := 14;
  
Word.Selection.Font.Bold     := True;
  
Word.Selection.TypeText(Text := Combobox1.Text);
  
Word.Selection.TypeParagraph;
  
Word.Selection.TypeParagraph;
  
Word.Selection.TypeParagraph;
  
Word.Selection.Font.Name := 'Times New Roman';
  
Word.Selection.Font.Size := 12;
  
Word.Selection.Font.Bold := True;
  case 
RadioGroup1.ItemIndex of
  0
: Word.Selection.TypeText(Text := 'First Item Selected... ' + edit1.Text);
  
1: Word.Selection.TypeText(Text := 'Second Item Selected...' + edit1.Text);
  
2: Word.Selection.TypeText(Text := 'Third item text... ' + edit1.Text);
  
end;
end; 
الأمثلة لـ Simon Grossenbacher بتصرف
الباقي عليك.
اللهم احقن دماء المسلمين، لا تنسوهم بالدعاء...
الرد


الردود في هذا الموضوع
ارسال صورة سطح المكتب لملف وورد من دلفي - بواسطة kachwahed - 27-02-2010, 11:44 PM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم