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 text at a Bookmark 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
05-Apr-03
Category
OLE
Language
Delphi 5.x
Views
107
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to insert text at a Bookmark

Answer:

1   uses
2     ComObj;
3   
4   procedure TForm1.Button1Click(Sender: TObject);
5   const
6     // Word Document to open
7     YourWordDocument = 'c:\test\worddoc.doc';
8   var
9     BookmarkName, Doc, R: OleVariant;
10  begin
11    // Start a Word instance
12    try
13      WordApp := CreateOleObject('Word.Application');
14    except
15      ShowMessage('Could not start MS Word!');
16    end;
17    // Open your Word document
18    WordApp.Documents.Open(YourWordDocument);
19    Doc := WordApp.ActiveDocument;
20  
21    // name of your bookmark
22    BookmarkName := 'MyBookMark';
23  
24    // Check if bookmark exists
25    if Doc.Bookmarks.Exists(BookmarkName) then
26    begin
27      R := Doc.Bookmarks.Item(BookmarkName).Range;
28      // Add text at our bookmark
29      R.InsertAfter('Text in bookmark');
30      // You make a text formatting like changing its color
31      R.Font.Color := clRed;
32    end;
33  
34    // Save your document and quit Word
35    if not VarIsEmpty(WordApp) then
36    begin
37      WordApp.DisplayAlerts := 0;
38      WordApp.Documents.Item(1).Save;
39      WordApp.Quit;
40      BookmarkName := Unassigned;
41      R := Unassigned;
42      WordApp := Unassigned;
43    end;
44  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