 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Sylvain Epic Guest
|
Posted: Wed Dec 15, 2004 5:35 pm Post subject: WinWord : Find doesn't match |
|
|
Hello
I want to find a text in a Winword document and replace it by picture. And
it's ok !
Except if text is in "text area" ( I'm not sure of english
translation. Please Tell me if it's wrong).
Can somebody help me ?
Thanks
S.
|
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Thu Dec 16, 2004 11:54 am Post subject: Re: WinWord : Find doesn't match |
|
|
<
I want to find a text in a Winword document and replace it
by picture. And it's ok !
Except if text is in "text area"
You can search the wdTextFrameStory storyrange.
Unfortunately if it doesn't exist because there are no
textboxes, you get an exception, so you need to trap that.
try
SearchRng := Doc.StoryRanges.Item(wdTextFrameStory);
SearchRng.Find.Execute('Text to find',
Wrap := wdFindContinue);
if SearchRng.Find.Found then
begin
SearchRng.Text := '';
Doc.InlineShapes.AddPicture('K:PicsHills.bmp',
EmptyParam, EmptyParam, SearchRng);
end;
except
on E: EOleSysError do begin end;
else raise;
end;
--
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 |
|
 |
Sylvain Epic Guest
|
Posted: Thu Dec 16, 2004 2:16 pm Post subject: Re: WinWord : Find doesn't match |
|
|
Thanks Deborah
But I've tried this :
try
Wrap := wdFindContinue;
MatchAllWordForms := False;
SelectRange := ActiveDocument.StoryRanges.Item(wdTextFrameStory);
// SelectRange.Find.Execute ( SearchText, Wrap := wdFindContinue);
Compilation error : "not enough parameters"
SelectRange.Find.Execute (
SearchText,//alse,False,True,False,False,OleForward,0,False,False);
MatchCase, MatchWholeWord, MatchWildcards,
emptyParam,MatchAllWordForms,
emptyParam, wrap, Format, emptyParam,
emptyParam );
if SelectRange.Find.Found then
begin
SelectRange.Select;
result := True;
end
else
result:= False;
And text is never found...
Do you have an idea ?
"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> a écrit dans
le message de news: [email]VA.00001fb4.00ae102e (AT) blueyonder (DOT) co.not-this-bit.uk[/email]...
| Quote: | Sylvain Epic:
I want to find a text in a Winword document and replace it
by picture. And it's ok !
Except if text is in "text area"
You can search the wdTextFrameStory storyrange.
Unfortunately if it doesn't exist because there are no
textboxes, you get an exception, so you need to trap that.
try
SearchRng := Doc.StoryRanges.Item(wdTextFrameStory);
SearchRng.Find.Execute('Text to find',
Wrap := wdFindContinue);
if SearchRng.Find.Found then
begin
SearchRng.Text := '';
Doc.InlineShapes.AddPicture('K:PicsHills.bmp',
EmptyParam, EmptyParam, SearchRng);
end;
except
on E: EOleSysError do begin end;
else raise;
end;
--
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: Thu Dec 16, 2004 2:44 pm Post subject: Re: WinWord : Find doesn't match |
|
|
<
SelectRange.Find.Execute ( SearchText, Wrap :=
wdFindContinue);
Compilation error : "not enough parameters"
Sorry, I should have made it clear that my SearchRng
variable was a variant. Microsoft recommends using late
binding (i.e. variants) with the Find.Execute method
anyway, because of bugs in early binding.
--
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 |
|
 |
Sylvain Epic Guest
|
Posted: Thu Dec 16, 2004 3:05 pm Post subject: Re: WinWord : Find doesn't match |
|
|
Thanks : I did it !
But one restriction : it works only if document gets one page.
If frame is on second page, find doesn't match...
Any tip ?
"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> a écrit dans
le message de news: [email]VA.00001fb8.014b7053 (AT) blueyonder (DOT) co.not-this-bit.uk[/email]...
| Quote: | Sylvain Epic:
SelectRange.Find.Execute ( SearchText, Wrap :=
wdFindContinue);
Compilation error : "not enough parameters"
Sorry, I should have made it clear that my SearchRng
variable was a variant. Microsoft recommends using late
binding (i.e. variants) with the Find.Execute method
anyway, because of bugs in early binding.
--
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 |
|
 |
|
|
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
|
|