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
CBuilder 5.x
Views
569
User Rating
9
# Votes
2
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			1   
2   //---------------------------------------------------------------------------
3   
4   #include <vcl.h>
5   #pragma hdrstop
6   #include <sysvari.h>
7   #include <ComObj.hpp>
8   #include <Clipbrd.hpp>
9   #include "Unit1.h"
10  //---------------------------------------------------------------------------
11  #pragma package(smart_init)
12  #pragma link "Word_2K_SRVR"
13  #pragma resource "*.dfm"
14  TForm1 *Form1;
15  //---------------------------------------------------------------------------
16  __fastcall TForm1::TForm1(TComponent* Owner)
17          : TForm(Owner)
18  {
19  }
20  //---------------------------------------------------------------------------
21  
22  void __fastcall TForm1::Button1Click(TObject *Sender)
23  {
24     TStringList* sl= new TStringList();
25     TClipboard *SysClip = new TClipboard();
26    try
27    {
28      try
29        {
30          WordApplication->Connect();
31        }
32      catch (Exception &exception)
33        {
34          MessageDlg("Word may not be installed", mtError, TMsgDlgButtons() << mbYes, 
35  0);
36          Abort;
37        }
38      WordApplication->GetDefaultInterface()->Visible = true;
39      WordApplication->set_Caption(StringToOleStr("DevSuperPage.com"));
40      //Create new document
41      //Turn Spell checking off because it takes a long time if enabled and slows 
42  down Winword
43      WordApplication->Options->CheckSpellingAsYouType = false;
44      WordApplication->Options->CheckGrammarAsYouType = false;
45      sl->LoadFromFile("c:\\test.txt");
46      SysClip->AsText =sl->Text;
47      SysClip->Free();
48      sl->Free();
49      WordDocument->Sentences->Last->Paste();
50  
51  
52    }
53    catch (Exception &exception)
54    {
55      Application->ShowException(&exception);
56      WordApplication->Disconnect();
57    }
58  
59  }
60  //---------------------------------------------------------------------------


			
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