BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

word

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Mats Gustafsson
Guest





PostPosted: Sat Dec 13, 2003 10:12 pm    Post subject: word Reply with quote



Hi
Question1:
Is there anyway i can read the text in a word-document which is at a certain
bookmark? Put text at a bookmark is easy, but how do i read from it?
Question2:
Is it possible to delete the text at a bookmark and replace it with some
other text?

Regards, Mats Gustafsson


Back to top
Deborah Pate (TeamB)
Guest





PostPosted: Sun Dec 14, 2003 7:09 pm    Post subject: Re: word Reply with quote



< Is there anyway i can read the text in a word-document
which is at a certain bookmark?
Quote:


var
Bkmk: Bookmark;
BookmarkName: OleVariant;
...
BookmarkName := 'MyBookmark';
Bkmk := Doc.Bookmarks.Item(BookmarkName);

{ Read text }
BookmarkText := Bkmk.Range.Text;

{ Replace it }
Bkmk.Range.Text := 'Inserting Text';


--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html



Back to top
Mats Gustafsson
Guest





PostPosted: Mon Dec 15, 2003 9:45 am    Post subject: Re: word Reply with quote



Thats what i suspected, but when i try to read text from a bookmark it comes
out empty even though there is a line of text at that bookmark?!?
BookMarkText is empty...

Regards, Mats

"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> skrev i
meddelandet news:VA.00001de1.422f3d1d (AT) blueyonder (DOT) co.not-this-bit.uk...
Quote:
Mats Gustafsson:
Is there anyway i can read the text in a word-document
which is at a certain bookmark?


var
Bkmk: Bookmark;
BookmarkName: OleVariant;
..
BookmarkName := 'MyBookmark';
Bkmk := Doc.Bookmarks.Item(BookmarkName);

{ Read text }
BookmarkText := Bkmk.Range.Text;

{ Replace it }
Bkmk.Range.Text := 'Inserting Text';


--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html





Back to top
Mats Gustafsson
Guest





PostPosted: Mon Dec 15, 2003 9:49 am    Post subject: Re: word Reply with quote

I want my inserted text to replace the old text at the bookmark, the command
insert text just adds more text and leaves the old text still at my
bookmark, is there anyway i can make my new text replace the old text at a
specific bookmark?
Regards, Mats

"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> skrev i
meddelandet news:VA.00001de1.422f3d1d (AT) blueyonder (DOT) co.not-this-bit.uk...
Quote:
Mats Gustafsson:
Is there anyway i can read the text in a word-document
which is at a certain bookmark?


var
Bkmk: Bookmark;
BookmarkName: OleVariant;
..
BookmarkName := 'MyBookmark';
Bkmk := Doc.Bookmarks.Item(BookmarkName);

{ Read text }
BookmarkText := Bkmk.Range.Text;

{ Replace it }
Bkmk.Range.Text := 'Inserting Text';


--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html





Back to top
Deborah Pate (TeamB)
Guest





PostPosted: Mon Dec 15, 2003 12:32 pm    Post subject: Re: word Reply with quote

< it comes out empty even though there is a line of text at
that bookmark?!?
Quote:


But does the bookmark /contain/ the text, or is it just
positioned before it? How have you inserted the bookmark
and the text?

--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html



Back to top
Deborah Pate (TeamB)
Guest





PostPosted: Mon Dec 15, 2003 12:32 pm    Post subject: Re: word Reply with quote

< the command insert text just adds more text
Quote:


No, doing
Bkmk.Range.Text := 'New text';
will replace any text that is in your bookmark's range. It
sounds as though the text you want to replace is after the
bookmark.

--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html



Back to top
Mats Gustafsson
Guest





PostPosted: Mon Dec 15, 2003 7:15 pm    Post subject: Re: word Reply with quote

Ok now i see the problem, the same as for Inserting/replacing...
I have positioned my bookmark at a blank character at position1 on a line
and then i insert my text from my Delphi Application. So how can i make the
App read the entire line instead of just my empty character at pos1? When i
create my bookmark i dont know how much text i will insert so thats why i
just placed the cursor at position1 and inserted a bookmark...Then i insert
my text from my App at that bookmark. Hope u understand my dilemma...
Regards, Mats


"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> skrev i
meddelandet news:VA.00001de6.45ebce96 (AT) blueyonder (DOT) co.not-this-bit.uk...
Quote:
Mats Gustafsson:
it comes out empty even though there is a line of text at
that bookmark?!?


But does the bookmark /contain/ the text, or is it just
positioned before it? How have you inserted the bookmark
and the text?

--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html





Back to top
Deborah Pate (TeamB)
Guest





PostPosted: Mon Dec 15, 2003 8:46 pm    Post subject: Re: word Reply with quote

< So how can i make the App read the entire line instead of
just my empty character at pos1?
Quote:


var
BM, HowMuch: olevariant;
Bkmk: Bookmark;
...
BM := 'BookmarkName';
Doc.Bookmarks.Item(BM).Range.Select;
HowMuch := wdLine;
Word.Selection.Expand(HowMuch);
Word.Selection.Text := 'This text will replace the line';

--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html



Back to top
Tony J Hopkinson
Guest





PostPosted: Mon Dec 15, 2003 8:46 pm    Post subject: Re: word Reply with quote

On Sat, 13 Dec 2003 23:12:34 +0100, "Mats Gustafsson"
<mats (AT) quickcode (DOT) se> wrote:

Quote:
Hi
Question1:
Is there anyway i can read the text in a word-document which is at a certain
bookmark? Put text at a bookmark is easy, but how do i read from it?
Question2:
Is it possible to delete the text at a bookmark and replace it with some
other text?

Regards, Mats Gustafsson

When you do this, set up your template with something like

Blah blah <MyBlahBlah Bookmark>. Hightlight the text to be
replaced name the bookmark and off you go. If you just put a bookmark
at the end of Blah Blah, it will be an empty one.




Back to top
Mats Gustafsson
Guest





PostPosted: Tue Dec 16, 2003 9:20 pm    Post subject: Re: word Reply with quote

Ok, thanx but this code also deletes the bookmark...
I want to keep my bookmark at the same place, do i have to insert a new one
or what??

my code:

var boknamn, langd : olevariant;
...
boknamn:='test';
WordDocument1.Bookmarks.Item(boknamn).Range.Select;
langd:=wdLine;
WordApplication1.Selection.Expand(langd);
WordApplication1.Selection.Text:='This text will replace the line';


"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> skrev i
meddelandet news:VA.00001de9.47b1118f (AT) blueyonder (DOT) co.not-this-bit.uk...
Quote:
Mats Gustafsson:
So how can i make the App read the entire line instead of
just my empty character at pos1?


var
BM, HowMuch: olevariant;
Bkmk: Bookmark;
..
BM := 'BookmarkName';
Doc.Bookmarks.Item(BM).Range.Select;
HowMuch := wdLine;
Word.Selection.Expand(HowMuch);
Word.Selection.Text := 'This text will replace the line';

--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html





Back to top
Deborah Pate (TeamB)
Guest





PostPosted: Tue Dec 16, 2003 11:40 pm    Post subject: Re: word Reply with quote

< I want to keep my bookmark at the same place, do i have to
insert a new one or what??
Quote:


Yes, that's probably the easiest way.

--
Deborah Pate (TeamB) http://delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.