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 

WinWord : Find doesn't match

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





PostPosted: Wed Dec 15, 2004 5:35 pm    Post subject: WinWord : Find doesn't match Reply with quote



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





PostPosted: Thu Dec 16, 2004 11:54 am    Post subject: Re: WinWord : Find doesn't match Reply with quote



< 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"
Quote:


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





PostPosted: Thu Dec 16, 2004 2:16 pm    Post subject: Re: WinWord : Find doesn't match Reply with quote



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





PostPosted: Thu Dec 16, 2004 2:44 pm    Post subject: Re: WinWord : Find doesn't match Reply with quote

< SelectRange.Find.Execute ( SearchText, Wrap :=
wdFindContinue);
Compilation error : "not enough parameters"
Quote:


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





PostPosted: Thu Dec 16, 2004 3:05 pm    Post subject: Re: WinWord : Find doesn't match Reply with quote

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
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.