Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Find object variables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Conan Kelly - 13 Nov 2006 20:44 GMT
Hello all,

Is there a way to create a Find Object variable?

I would like to create 2 different Find Object variables and assign different "text to find" (selection.find.text property) to each
variable where they won't interfere with/change one another.

Is this possible?  If so, please provide sample code.

Signature

Thanks for any help anyone can provide,

Conan Kelly

Jean-Guy Marcil - 13 Nov 2006 22:11 GMT
Conan Kelly was telling us:
Conan Kelly nous racontait que :

> Hello all,
>
[quoted text clipped - 4 lines]
> variable where they won't interfere with/change one another.
> Is this possible?  If so, please provide sample code.

I am not sure I follow what you intend to do...

Why not just run the Find twice, back to back?

You could have a parameterized Function that accept the "text" as a
parameter and return the result.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Conan Kelly - 13 Nov 2006 22:33 GMT
Jean-Guy,

Thank you for your feed back.

I guess that I will have to do that.

I have a long report.  At the end of each section in the report, there is a summary on that section.  Sometimes that summary can
spill over onto the next page.

I was trying to search for the string for the start of the first summary so I can find the starting position of the first summary.
Then I was searching for the next page break:  the end of that summary.  After I select the summary and cut it out, I now need to
search for a 2nd page of the same summary.  I was doing this by using a Do While loop:

       Selection.Find.Text = pstrSearchStrings(pintIndex)
       Do While Selection.Find.Execute

well, within my Do While loop, I need to switch the text to look for the page break:

           Selection.Find.Execute "^m"

now, if I don't switch my Find.Text back to the original setting, the Do While loop will not work correctly:

       Selection.Find.Text = pstrSearchStrings(pintIndex)
       Do While Selection.Find.Execute
           ...
           Selection.Find.Execute "^m"
           ...
           ...
           Selection.Find.Text = pstrSearchStrings(pintIndex)
       Loop

I was hoping that it was possible to create 2 different Find Object variables and set the Find.Text for each of those variables to
somthing different.  Something like:

   Dim pfndPageBreak as New Find
   Dim pfndSummaryText as New Find

   pfndPageBreak.Text = "^m"
   pfndSummaryText.Text = pstrSearchStrings(pintIndex)

and then my Do While would look something like this:

       Do While pfndSummaryText.Execute
           ...
           pfndPageBreak.Execute
           ...
           ...
           'Selection.Find.Text = pstrSearchStrings(pintIndex)        '<-- This line would not be needed anymore
       Loop

But that doesn't work.  As soon as I switch to look for a page break, it changes my Find.Text in the whole application and if I
don't reset my Find.Text back to it's original setting, the Do While loop won't work correctly.

Thanks again for all of your help,

Conan Kelly

> Conan Kelly was telling us:
> Conan Kelly nous racontait que :
[quoted text clipped - 13 lines]
>
> You could have a parameterized Function that accept the "text" as a parameter and return the result.
Jean-Guy Marcil - 14 Nov 2006 02:22 GMT
Conan Kelly was telling us:
Conan Kelly nous racontait que :

> Jean-Guy,
>
[quoted text clipped - 16 lines]
> well, within my Do While loop, I need to switch the text to look for
> the page break:

You could try something like this instead:

Dim strSummary As String

strSummary = "Summary"

Selection.HomeKey wdStory

With Selection.Find
   .Text = strSummary
   Do While .Execute
       With Selection
           .MoveEndUntil Chr(12), wdForward
           .MoveRight wdCharacter, 1, wdExtend
           .Delete
       End With
   Loop
End With

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.