| View previous topic :: View next topic |
| Author |
Message |
Mats Gustafsson Guest
|
Posted: Sat Dec 13, 2003 10:12 pm Post subject: word |
|
|
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
|
Posted: Sun Dec 14, 2003 7:09 pm Post subject: Re: word |
|
|
<
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
|
Posted: Mon Dec 15, 2003 9:45 am Post subject: Re: word |
|
|
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
|
Posted: Mon Dec 15, 2003 9:49 am Post subject: Re: word |
|
|
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
|
Posted: Mon Dec 15, 2003 12:32 pm Post subject: Re: word |
|
|
<
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
|
Posted: Mon Dec 15, 2003 12:32 pm Post subject: Re: word |
|
|
<
the command insert text just adds more text
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
|
Posted: Mon Dec 15, 2003 7:15 pm Post subject: Re: word |
|
|
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
|
Posted: Mon Dec 15, 2003 8:46 pm Post subject: Re: word |
|
|
<
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 |
|
 |
Tony J Hopkinson Guest
|
Posted: Mon Dec 15, 2003 8:46 pm Post subject: Re: word |
|
|
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
|
Posted: Tue Dec 16, 2003 9:20 pm Post subject: Re: word |
|
|
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
|
Posted: Tue Dec 16, 2003 11:40 pm Post subject: Re: word |
|
|
<
I want to keep my bookmark at the same place, do i have to
insert a new one or what??
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 |
|
 |
|