Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to insert a text file in a word document. Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Insert text file in a word document 15-May-04
Category
MS-Office
Language
Delphi 5.x
Views
707
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			1   
2   unit Unit1;
3   
4   interface
5   
6   uses
7     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
8     Dialogs,Clipbrd, StdCtrls, Word2000, OleServer;
9   
10  type
11    TForm1 = class(TForm)
12      Button1: TButton;
13      WordApplication: TWordApplication;
14      WordDocument: TWordDocument;
15      procedure Button1Click(Sender: TObject);
16    private
17      { Private declarations }
18    public
19      { Public declarations }
20    end;
21  
22  var
23    Form1: TForm1;
24  
25  implementation
26  
27  {$R *.dfm}
28  
29  procedure TForm1.Button1Click(Sender: TObject);
30  var
31  sl:TStringlist;
32  sysClip:TClipboard;
33  begin
34  
35    sl := TStringList.create;
36    SysClip := TClipboard.create;
37    try
38  
39      try
40  
41          WordApplication.Connect;
42  
43     except on E:Exception do begin
44  
45          MessageDlg('Word may not be installed', mtError, [mbYes], 0);
46          Abort;
47     end;
48     end;
49      WordApplication.Visible := True;
50      WordApplication.Caption:='DevSuperPage.com';
51      //Create new document
52      //Turn Spell checking off because it takes a long time if enabled and slows 
53  down Winword
54      WordApplication.Options.CheckSpellingAsYouType := False;
55      WordApplication.Options.CheckGrammarAsYouType := False;
56      sl.LoadFromFile('c:\test.txt');
57      SysClip.AsText :=sl.Text;
58      SysClip.Free;
59      sl.Free;
60       WordDocument.Sentences.Last.Paste;
61     except on E:Exception do begin
62      Application.ShowException(E);
63      WordApplication.Disconnect;
64  
65   end;
66   end;
67  end;
68  
69  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC