Find all

P

Pat L

Normally I use range.find instead of selection.find so as
not to leave Word's find dialog set to whatever search
parameters were utilized in the last search via a macro.

Okay, that said, I have a situation where I actually want
to use selection.find in a macro and then reset the find
dialog programmatically a few steps later in the user's
workflow. All is well except I can't seem to figure out
how to reset the "Search:" option to "All."

..Forward=True results in "Down" the next time the find
dialog is opened.
..Forward=False results in "Up" the next time the find
dialog is opened.

Any leads on having it set to "All" the next time the
find dialog opens?

Thanks,

Pat
 
P

Pat L

I do use the ClearFormatting method. Doesn't work after a
macro that uses selection.find and sets the Forward
propert to true or false. Here is an example with my
ResetFindDialog macro. On my XP machine, running Word
2002, if I run 'Example' and then open Word's find
dialog, 'Find Down' is still applied. Perhaps this is a
bug?

Sub Example()
With selection.Find
.ClearFormatting
.Forward = True
.Wrap = wdFindStop
.Text = selection.Text
.Execute
End With
ResetFindDialog
End Sub
Sub ResetFindDialog()
With selection.Find
.Text = ""
.ClearFormatting
.MatchCase = False
.MatchSoundsLike = False
.MatchWholeWord = False
.Wrap = wdFindContinue
.MatchAllWordForms = False
End With
End Sub
 
C

Chad DeMeyer

The "All" in the Find dialog actually corresponds to the combination in VBA
of .Forward=True and .Wrap=wdFindContinue.

cjd
 
P

Pat L

Thanks. I had tried that too. No luck.
-----Original Message-----
The "All" in the Find dialog actually corresponds to the combination in VBA
of .Forward=True and .Wrap=wdFindContinue.

cjd





.
 
H

Helmut Weber

Hi Pat,
this is what i am using:
Sub Resetsearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
End Sub
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 
J

Jezebel

Not on my machine it doesn't. I'd always assumed that is was a combination
of these two as you describe, but I tested it and it just ain't the case.
Interesting that we're all getting different results. On my machine using
ClearFormatting does indeed set it back to ALL.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Jezebel > écrivait :
In this message, < Jezebel > wrote:

|| Not on my machine it doesn't. I'd always assumed that is was a
combination
|| of these two as you describe, but I tested it and it just ain't the case.
|| Interesting that we're all getting different results. On my machine using
|| ClearFormatting does indeed set it back to ALL.
||

Strange... it should not work though. According to the VBA help,
ClearFormatting is for resetting character and paragraph attributes, it has
no impact on .Forward, .MatchCase or .MatchWholeWord for example.

On my machine (Word XP), nothing works. Not Pat's code, not Helmut and not
yours!
If I mess with Forward... I cannot set it back to "All".

I do not understand why a variable supposedly dealing with three states
(Forward, Backward and All) was created as Boolean....!?!

In fact, IMHO, the error is not in VBA, but in the dialog itself. Forward
and Backward are searches limited to the main story. "All", OTOH, will
search headers, footers, end notes... as well as the main story. This
behaviour deserves its own separate setting, and this is why it is annoying
that we cannot set it back to All.. A user could be frustrated that a search
fails (after using code) when he/she knows that the text to be found exists
in a header, but the user does not know that all they have to do is reset
the forward setting to All...
Confusing for anyone who does not know. How are you supposed to guess that
ALL includes Headers, but Forward doesn't?

Another one for MSWish.com!


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jezebel

You might be right about it being a quirk of the dialog itself, because
there's at least one other with this problem: select a table cell, then
display the Table Properties dialog. Go to the Cell tab and click the
Options button. Note the 'Same as whole table' checkbox. You can clear this
checkbox through code by setting any of the cell's padding values; but there
seems to be no way to check this checkbox through code.
 
W

Word Heretic

G'day "Jezebel" <[email protected]>,

Did you try setting back to the original values from

Tables(1).RightPadding etc?

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Jezebel reckoned:
 
J

Jezebel

Yes of course I tried that :) Unfortuantely it doesn't solve the problem.
Although it (obviously) makes the cell's padding match the rest of the
table, if the padding for the table as a whole is subsequently changed, that
cell will not change with it.
 
P

Pat L

Yes, I too am baffled by the conflict between the
boolean .forward/.backward options and a third option in
the dialog.

Thanks for all your efforts, everyone.

Pat
 
W

Word Heretic

G'day "Jezebel" <[email protected]>,

Just dreaming on for a sec, one could set the table.cells properties
en masse, it would of course destroy any other existing
customizations, but one could scan for those prior and reset if
needed. Maybe that might do it.

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Jezebel reckoned:
 
J

Jezebel

Thanks for the pondering, but unfortunately it ain't so easy.

The point of the exercise is this: I have a function that adjusts the height
of a table by setting the bottom padding for the table as a whole -- single
setting, very quick. But there are some cells to which the global padding
value does not apply: header rows, the last row, and cells containing nested
tables. These are handled by the code equivalent of clearing the 'Same as
whole table' checkbox and setting the bottom padding explicitly for each
affected cell.

The problem comes if, for example, a new row is added to the end of the
table or a nested table is deleted: the affected cells should now revert to
'Same as whole table' so that the table as a whole is correctly spaced and
further calls to the spacing function will work correctly. This is easy
enough as a one-off (we've added a new row, so fix the cells in the
penultimate row); but if we then add yet another row or move the rows
around, there's no easy way to distinguish the cells that are not 'same as
whole table' because they used to be special and are no longer (and thus
should be adjusted) from those that are still special (and thus should be
left alone).
 
W

Word Heretic

G'day "Jezebel" <[email protected]>,

Yeah - not good. When adding you'd have to explicitly set them, but
then they wont follow the table.

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Jezebel reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top