![]() |
|
|
||||||||
| Site Links |
| Consulting |
| Knowledge Base |
| Training |
| Forum |
| Articles |
| Resources |
| Products |
| Cool Tools |
| Contact |
| About Us |
| Go to Page... |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
|
I am attempting to find text with no regards to case. ".MatchCase = False" (or true) does not work.
This is what I am using: With Selection.Find .Forward = True .MatchWholeWord = True .MatchCase = False .Wrap = wdFindContinue .Font.Bold = False 'If I DONT put his in, it will only find Bold text .Execute FindText:="Client"End With The word "client" below will not be found / selected. ".......bla bla bla client bla bla bla" Here it will find and select the word "Client" , even with matchcase=False. ".......bla bla bla Client bla bla bla" Thanks for any help |
|
Local Time: 01:27 AM
Local Date: 05-20-2013 Location:
|
|
|
|
#2 |
|
|
Put
in the Find loop and see if it gives the expected results Paul |
|
Local Time: 05:27 AM
Local Date: 05-20-2013 Location:
|
|
|
|
#3 |
|
|
.Format
Does not fix issue, Mike |
|
Local Time: 01:27 AM
Local Date: 05-20-2013 Location:
|
|
|
|
#4 |
|
|
This finds 'Client' or 'client' on my machine.
VBA:
VBA tags courtesy of www.thecodenet.com
+------+ | David | +------+ |
|
Local Time: 03:27 AM
Local Date: 05-20-2013 Location:
|
|
|
|
#5 |
|
|
You should record the macro which does this and use all of the items you find, or go away from the Selection object entirely and start to use the range object.
The problem you're having, I suspect, is that Selection.Find object can "remember" various settings. There are a lot of variables at play here, but why don't you start with showing us a recorded macro (if you are not a programmer) or use the range object (if you are) and tell us the version number. Obviously .MatchCase as a property of the Find object for Microsoft Word is not entirely broken, so we'll probably need a few more details. Remember to use the VBA tags, please! |
|
Local Time: 05:27 AM
Local Date: 05-20-2013 Location:
|
|
|
|
#6 |
|
|
OK,
I did not realize that Word could record all of the options while recording. Here is what it recorded when I ran the recorder, which works. Selection.Find.ClearFormatting With Selection.Find .Text = "Client" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Font.Bold = True End With Selection.Find.Execute I added the ".Font.Bold=True" , which also pays attention to bold words. Thanks all for your input. Mike |
|
Local Time: 01:27 AM
Local Date: 05-20-2013 Location:
|
|
|
|
#7 |
|
|
I believe that if you have .Format = False that will make .Font.Bold = True meaningless (i.e., you'll find the bold words regardless).
But you can play around with different finds while you record macros to see what shows up. And check out the vba tags... bracket "[" and VBA and "]" and then close off your code with a backslash. There's also a button... it really makes your code much easier to read. |
|
Local Time: 05:27 AM
Local Date: 05-20-2013 Location:
|
|
|
|
#8 |
|
|
Hi Mike,
Word will find both bold and non-bold text without the ".Font.Bold=True" directive. In fact, with that directive appearing after the ".Format = False" directive, it will only find bold text. Cheers Paul Edstein [MS MVP - Word] |
|
Local Time: 07:27 PM
Local Date: 05-20-2013 Location:
|
|
|
|
#9 |
|
|
OK,
After a lot more research, ".MatchWildCards" =True will render ".MatchCase" =False useless. You can not search case insensitive. A search for "Mike * Johnson" will not find find "mike tom johnson", and a search for "Mike" will not find "mike' Thanks Microsoft. Mike |
|
Local Time: 01:27 AM
Local Date: 05-20-2013 Location:
|
|
|
|
#10 |
|
|
Hi Mike,
Your 'Thanks Microsoft' speaks of intemperence instead of one taking the time to learn how to use the tools at their disposal. It is true that ".MatchCase = True" is of no effect if ".MatchWildCards =True', but that doesn't mean you can't check for upper & lower cases in a wildcard Find. A wildcard Find for "[Mm]ike *[Jj]ohnson" will find: mike johnson, mike Johnson, Mike johnson, Mike Johnson, mike xxx johnson, mike xxx Johnson, Mike xxx johnson, Mike xxx Johnson, mike tom dick harry johnson, mike tom dick harry Johnson, Mike tom dick harry johnson, Mike tom dick harry Johnson, etc. Wildcard Find/Replace expressions can be quite powerful. Consider: Find = (<[MTWFSondayueshrit]{3,8},)( [JFMASONDanuryebchpilgstmov]{3,9})( [0-9]{1,2}[dhnrst]{2}),( [12][0-9]{3}>) Replace = \1\3\2\4 Cheers Paul Edstein [MS MVP - Word] |
|
Local Time: 07:27 PM
Local Date: 05-20-2013 Location:
|
|
|
|
#11 |
|
|
Oldie but a goodie...
http://word.mvps.org/faqs/General/UsingWildcards.htm |
|
Local Time: 05:27 AM
Local Date: 05-20-2013 Location:
|
|
![]() |
| Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|


