Find x OR y OR z

J

Johann Swart

Is it possible to use the Find (Search) function to find either January or
February or March, etc, perhaps by using a macro? I would like not to have to
use 12 different searches to search for the 12 months.
The action after having found a particular month varies; I manually apply an
action and then resume the search to the next incidence.
 
P

Pesach Shelnitz

Hi Johann,

I was tempted to tell you that this could be done using a wildcard search,
but since the names of the months have different lengths and May consists of
only three letters, siuch a search would find many other words besides the
names of the months. I therefore wrote the following macro which searches
through the doc 12 times, but since it performs the searches on a Range
object rather than the Selection object, it can do the work quickly even in a
large doc.

Sub FindMonths()
Dim monthArray As Variant
Dim myRange As Range
Dim i As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
Set myRange = ActiveDocument.Range
With myRange
For i = 1 To 12
.Start = 0
Do While .Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True
Select Case i
Case 1
' Replace the following line by the actions
' to be performed when January is found.
MsgBox "January found at " & .Start
Case 2
' Replace the following line by the actions
' to be performed when February is found.
MsgBox "February found at " & .Start
Case 3
' Replace the following line by the actions
' to be performed when March is found.
MsgBox "March found at " & .Start
Case 4
' Replace the following line by the actions
' to be performed when April is found.
MsgBox "April found at " & .Start
Case 5
' Replace the following line by the actions
' to be performed when May is found.
MsgBox "May found at " & .Start
Case 6
' Replace the following line by the actions
' to be performed when June is found.
MsgBox "June found at " & .Start
Case 7
' Replace the following line by the actions
' to be performed when July is found.
MsgBox "July found at " & .Start
Case 8
' Replace the following line by the actions
' to be performed when August is found.
MsgBox "August found at " & .Start
Case 9
' Replace the following line by the actions
' to be performed when September is found.
MsgBox "September found at " & .Start
Case 10
' Replace the following line by the actions
' to be performed when October is found.
MsgBox "October found at " & .Start
Case 11
' Replace the following line by the actions
' to be performed when November is found.
MsgBox "November found at " & .Start
Case 12
' Replace the following line by the actions
' to be performed when December is found.
MsgBox "December found at " & .Start
End Select
.MoveStart 1
.End = ActiveDocument.Range.End
Loop
Next
End With
Set myRange = Nothing
End Sub
 
J

Johann Swart

Toda Pesach
One question though: What is the significance of the report e.g. "July found
at 19598"? Is there perhaps some way it can take me to that incidence?
Shalom
 
D

Doug Robbins - Word MVP

To do that, use:

Sub FindaMonth()
Dim monthArray As Variant
Dim i As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
For i = 1 To 12
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then
Exit Sub
End If
Next
MsgBox "There are no months in the document." 'Just in case there are
no months and you thought that nothing was happening.
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
P

Pesach Shelnitz

Shalom Johann,

I included these pop-up messages so that you can follow the operation of the
macro as it performs the searches and, as the comment preceding the code for
each of them indicates, so that you would have a placemarker for inserting
your code to process the data found. Each time the macro finds what it is
looking for, the start and end positions of the Range object (myRange) are
set to the start and end positions of the search string found in the
document. If you just want to go to the first month name found and proceed
manually, the Range object offers little benefit and you can use Doug's
version with the Selection object. If you want your code to do the work, the
Range object can provide access to all the information needed to do that work
for each incidence as the macro finds it. To see what I mean, add the
following lines after one or more of the lines containing MsgBox.

.Select
MsgBox "Now you can see " & .Text & " selected."

I want to emphasize that by using the Range object and not selecting the
text found, the macro can perform all the work silently with much greater
speed. If you would describe what you want the macro to do when it finds the
name of a month, I or the others can help you more.

Best regards,
Pesach
 
J

Johann Swart

Hi Doug,
When running your code, I get the following:
"Microsoft Visual Basic
Run-time error 5623 The Replace With text contains a group number which is
out of range. [Continue] [End] [Debug] [Help]"
Pushing the [Debug] key highlights the following text:
"If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then"
I copied your code exactly.
 
D

Doug Robbins - Word MVP

See the article "Clear settings from Find and Replace dialog to prevent
unexpected results from future Find or Replace operations†at:

http://www.word.mvps.org/FAQs/MacrosVBA/ClearFind.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Johann Swart said:
Hi Doug,
When running your code, I get the following:
"Microsoft Visual Basic
Run-time error 5623 The Replace With text contains a group number which is
out of range. [Continue] [End] [Debug] [Help]"
Pushing the [Debug] key highlights the following text:
"If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then"
I copied your code exactly.



Doug Robbins - Word MVP said:
To do that, use:

Sub FindaMonth()
Dim monthArray As Variant
Dim i As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
For i = 1 To 12
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then
Exit Sub
End If
Next
MsgBox "There are no months in the document." 'Just in case there
are
no months and you thought that nothing was happening.
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

Johann Swart

Hi guys,
Thanks indeed for your patience.
The document I am referring to is a monthly project progress report Word
document (100+ pages) containing numerous dates: target dates, completion
dates, milestone dates, payment dates, etc
Each month the report is updated according to MS Project info and stats.
In practice, every month I go through the report and verify the validity of
information, especially adherence to the schedule dates. Often a date needs
to be adjusted, or else left as is.
To speed up the process, it would help if one has a macro that can jump from
one date to the next, irrespective of what month appears next.
Having found a date in the document, I manually compare it to the MS Project
data then either adjust it or leave it as is. The macro should then proceed
to the next date.
As I said, it is just a means to update the document in the shortest
possbile time and not having to read the entire document to avoid missing any
dates.

I did run the "Clear" macro as Doug suggested, but then the macro seems to
get stuck on the first incidence of a month. Am I doing something wrong or
not doing something?

Doug Robbins - Word MVP said:
See the article "Clear settings from Find and Replace dialog to prevent
unexpected results from future Find or Replace operations†at:

http://www.word.mvps.org/FAQs/MacrosVBA/ClearFind.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Johann Swart said:
Hi Doug,
When running your code, I get the following:
"Microsoft Visual Basic
Run-time error 5623 The Replace With text contains a group number which is
out of range. [Continue] [End] [Debug] [Help]"
Pushing the [Debug] key highlights the following text:
"If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then"
I copied your code exactly.



Doug Robbins - Word MVP said:
To do that, use:

Sub FindaMonth()
Dim monthArray As Variant
Dim i As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
For i = 1 To 12
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then
Exit Sub
End If
Next
MsgBox "There are no months in the document." 'Just in case there
are
no months and you thought that nothing was happening.
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Toda Pesach
One question though: What is the significance of the report e.g. "July
found
at 19598"? Is there perhaps some way it can take me to that incidence?
Shalom

:

Hi Johann,

I was tempted to tell you that this could be done using a wildcard
search,
but since the names of the months have different lengths and May
consists
of
only three letters, siuch a search would find many other words besides
the
names of the months. I therefore wrote the following macro which
searches
through the doc 12 times, but since it performs the searches on a
Range
object rather than the Selection object, it can do the work quickly
even
in a
large doc.

Sub FindMonths()
Dim monthArray As Variant
Dim myRange As Range
Dim i As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
Set myRange = ActiveDocument.Range
With myRange
For i = 1 To 12
.Start = 0
Do While .Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True
Select Case i
Case 1
' Replace the following line by the actions
' to be performed when January is found.
MsgBox "January found at " & .Start
Case 2
' Replace the following line by the actions
' to be performed when February is found.
MsgBox "February found at " & .Start
Case 3
' Replace the following line by the actions
' to be performed when March is found.
MsgBox "March found at " & .Start
Case 4
' Replace the following line by the actions
' to be performed when April is found.
MsgBox "April found at " & .Start
Case 5
' Replace the following line by the actions
' to be performed when May is found.
MsgBox "May found at " & .Start
Case 6
' Replace the following line by the actions
' to be performed when June is found.
MsgBox "June found at " & .Start
Case 7
' Replace the following line by the actions
' to be performed when July is found.
MsgBox "July found at " & .Start
Case 8
' Replace the following line by the actions
' to be performed when August is found.
MsgBox "August found at " & .Start
Case 9
' Replace the following line by the actions
' to be performed when September is found.
MsgBox "September found at " & .Start
Case 10
' Replace the following line by the actions
' to be performed when October is found.
MsgBox "October found at " & .Start
Case 11
' Replace the following line by the actions
' to be performed when November is found.
MsgBox "November found at " & .Start
Case 12
' Replace the following line by the actions
' to be performed when December is found.
MsgBox "December found at " & .Start
End Select
.MoveStart 1
.End = ActiveDocument.Range.End
Loop
Next
End With
Set myRange = Nothing
End Sub

--
Hope this helps,
Pesach Shelnitz


:

Is it possible to use the Find (Search) function to find either
January
or
February or March, etc, perhaps by using a macro? I would like not
to
have to
use 12 different searches to search for the 12 months.
The action after having found a particular month varies; I manually
apply an
action and then resume the search to the next incidence.
 
P

Pesach Shelnitz

Hi Johann,

Since you need to make the changes manually, you can run the following again
after it finds each month. Each search will continue from the location of the
cursor when you run the macro.

Sub FindMonths()
Dim monthArray As Variant
Dim resultArray As Variant
Dim myRange As Range
Dim i As Long
Dim pos As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
ReDim resultArray(12) As Long
Set myRange = ActiveDocument.Range
pos = Selection.start
myRange.start = pos
With myRange
For i = 1 To 12
.start = pos
If .Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then
resultArray(i - 1) = myRange.start
Else
resultArray(i - 1) = ActiveDocument.Range.End
End If
Next
End With
pos = resultArray(0)
For i = 1 To 12
If resultArray(i - 1) < pos Then
pos = resultArray(i - 1)
End If
Next
If pos <> ActiveDocument.Range.End Then
myRange.start = pos
myRange.End = pos
myRange.Select
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Else
MsgBox "There are no more month names in the document."
End If
Set myRange = Nothing
End Sub


Best regards,
Pesach
 
D

Doug Robbins - Word MVP

The following modification of Pesach's code may work better for you as if no
change is required to the month, you do not have to manually collapse the
selection before running the macro again. To facilitate it's use, I would
add a button to a toolbar, or in Word 2007 the Quick Access Toolbar to run
it.

Sub FindMonths()
Dim monthArray As Variant
Dim resultArray As Variant
Dim myRange As Range
Dim i As Long
Dim pos As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
ReDim resultArray(12) As Long
Set myRange = ActiveDocument.Range
pos = Selection.Start
myRange.Start = pos
With myRange
For i = 1 To 12
.Start = pos
If .Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then
resultArray(i - 1) = myRange.Start
Else
resultArray(i - 1) = ActiveDocument.Range.End
End If
Next
End With
pos = resultArray(0)
For i = 1 To 12
If resultArray(i - 1) < pos Then
pos = resultArray(i - 1)
End If
Next
If pos <> ActiveDocument.Range.End Then
myRange.Start = pos
myRange.End = pos
myRange.Select
Selection.Collapse wdCollapseEnd 'this command added
Selection.MoveRight Unit:=wdWord, Count:=1 ', Extend deleted
Else
MsgBox "There are no more month names in the document."
End If
Set myRange = Nothing
'End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Johann Swart said:
Hi guys,
Thanks indeed for your patience.
The document I am referring to is a monthly project progress report Word
document (100+ pages) containing numerous dates: target dates, completion
dates, milestone dates, payment dates, etc
Each month the report is updated according to MS Project info and stats.
In practice, every month I go through the report and verify the validity
of
information, especially adherence to the schedule dates. Often a date
needs
to be adjusted, or else left as is.
To speed up the process, it would help if one has a macro that can jump
from
one date to the next, irrespective of what month appears next.
Having found a date in the document, I manually compare it to the MS
Project
data then either adjust it or leave it as is. The macro should then
proceed
to the next date.
As I said, it is just a means to update the document in the shortest
possbile time and not having to read the entire document to avoid missing
any
dates.

I did run the "Clear" macro as Doug suggested, but then the macro seems to
get stuck on the first incidence of a month. Am I doing something wrong or
not doing something?

Doug Robbins - Word MVP said:
See the article "Clear settings from Find and Replace dialog to prevent
unexpected results from future Find or Replace operations†at:

http://www.word.mvps.org/FAQs/MacrosVBA/ClearFind.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Johann Swart said:
Hi Doug,
When running your code, I get the following:
"Microsoft Visual Basic
Run-time error 5623 The Replace With text contains a group number which
is
out of range. [Continue] [End] [Debug] [Help]"
Pushing the [Debug] key highlights the following text:
"If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then"
I copied your code exactly.



:

To do that, use:

Sub FindaMonth()
Dim monthArray As Variant
Dim i As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
For i = 1 To 12
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then
Exit Sub
End If
Next
MsgBox "There are no months in the document." 'Just in case there
are
no months and you thought that nothing was happening.
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
message
Toda Pesach
One question though: What is the significance of the report e.g.
"July
found
at 19598"? Is there perhaps some way it can take me to that
incidence?
Shalom

:

Hi Johann,

I was tempted to tell you that this could be done using a wildcard
search,
but since the names of the months have different lengths and May
consists
of
only three letters, siuch a search would find many other words
besides
the
names of the months. I therefore wrote the following macro which
searches
through the doc 12 times, but since it performs the searches on a
Range
object rather than the Selection object, it can do the work quickly
even
in a
large doc.

Sub FindMonths()
Dim monthArray As Variant
Dim myRange As Range
Dim i As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December",
",")
Set myRange = ActiveDocument.Range
With myRange
For i = 1 To 12
.Start = 0
Do While .Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True
Select Case i
Case 1
' Replace the following line by the actions
' to be performed when January is found.
MsgBox "January found at " & .Start
Case 2
' Replace the following line by the actions
' to be performed when February is found.
MsgBox "February found at " & .Start
Case 3
' Replace the following line by the actions
' to be performed when March is found.
MsgBox "March found at " & .Start
Case 4
' Replace the following line by the actions
' to be performed when April is found.
MsgBox "April found at " & .Start
Case 5
' Replace the following line by the actions
' to be performed when May is found.
MsgBox "May found at " & .Start
Case 6
' Replace the following line by the actions
' to be performed when June is found.
MsgBox "June found at " & .Start
Case 7
' Replace the following line by the actions
' to be performed when July is found.
MsgBox "July found at " & .Start
Case 8
' Replace the following line by the actions
' to be performed when August is found.
MsgBox "August found at " & .Start
Case 9
' Replace the following line by the actions
' to be performed when September is found.
MsgBox "September found at " & .Start
Case 10
' Replace the following line by the actions
' to be performed when October is found.
MsgBox "October found at " & .Start
Case 11
' Replace the following line by the actions
' to be performed when November is found.
MsgBox "November found at " & .Start
Case 12
' Replace the following line by the actions
' to be performed when December is found.
MsgBox "December found at " & .Start
End Select
.MoveStart 1
.End = ActiveDocument.Range.End
Loop
Next
End With
Set myRange = Nothing
End Sub

--
Hope this helps,
Pesach Shelnitz


:

Is it possible to use the Find (Search) function to find either
January
or
February or March, etc, perhaps by using a macro? I would like
not
to
have to
use 12 different searches to search for the 12 months.
The action after having found a particular month varies; I
manually
apply an
action and then resume the search to the next incidence.
 
J

Johann Swart

Hi Doug/Pesach

This latest code is exactly what I had in mind.

Thanks a million guys; you the greatest!

Regards
Johann

Doug Robbins - Word MVP said:
The following modification of Pesach's code may work better for you as if no
change is required to the month, you do not have to manually collapse the
selection before running the macro again. To facilitate it's use, I would
add a button to a toolbar, or in Word 2007 the Quick Access Toolbar to run
it.

Sub FindMonths()
Dim monthArray As Variant
Dim resultArray As Variant
Dim myRange As Range
Dim i As Long
Dim pos As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
ReDim resultArray(12) As Long
Set myRange = ActiveDocument.Range
pos = Selection.Start
myRange.Start = pos
With myRange
For i = 1 To 12
.Start = pos
If .Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then
resultArray(i - 1) = myRange.Start
Else
resultArray(i - 1) = ActiveDocument.Range.End
End If
Next
End With
pos = resultArray(0)
For i = 1 To 12
If resultArray(i - 1) < pos Then
pos = resultArray(i - 1)
End If
Next
If pos <> ActiveDocument.Range.End Then
myRange.Start = pos
myRange.End = pos
myRange.Select
Selection.Collapse wdCollapseEnd 'this command added
Selection.MoveRight Unit:=wdWord, Count:=1 ', Extend deleted
Else
MsgBox "There are no more month names in the document."
End If
Set myRange = Nothing
'End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Johann Swart said:
Hi guys,
Thanks indeed for your patience.
The document I am referring to is a monthly project progress report Word
document (100+ pages) containing numerous dates: target dates, completion
dates, milestone dates, payment dates, etc
Each month the report is updated according to MS Project info and stats.
In practice, every month I go through the report and verify the validity
of
information, especially adherence to the schedule dates. Often a date
needs
to be adjusted, or else left as is.
To speed up the process, it would help if one has a macro that can jump
from
one date to the next, irrespective of what month appears next.
Having found a date in the document, I manually compare it to the MS
Project
data then either adjust it or leave it as is. The macro should then
proceed
to the next date.
As I said, it is just a means to update the document in the shortest
possbile time and not having to read the entire document to avoid missing
any
dates.

I did run the "Clear" macro as Doug suggested, but then the macro seems to
get stuck on the first incidence of a month. Am I doing something wrong or
not doing something?

Doug Robbins - Word MVP said:
See the article "Clear settings from Find and Replace dialog to prevent
unexpected results from future Find or Replace operations†at:

http://www.word.mvps.org/FAQs/MacrosVBA/ClearFind.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Hi Doug,
When running your code, I get the following:
"Microsoft Visual Basic
Run-time error 5623 The Replace With text contains a group number which
is
out of range. [Continue] [End] [Debug] [Help]"
Pushing the [Debug] key highlights the following text:
"If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then"
I copied your code exactly.



:

To do that, use:

Sub FindaMonth()
Dim monthArray As Variant
Dim i As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December", ",")
For i = 1 To 12
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
If Selection.Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True Then
Exit Sub
End If
Next
MsgBox "There are no months in the document." 'Just in case there
are
no months and you thought that nothing was happening.
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
message
Toda Pesach
One question though: What is the significance of the report e.g.
"July
found
at 19598"? Is there perhaps some way it can take me to that
incidence?
Shalom

:

Hi Johann,

I was tempted to tell you that this could be done using a wildcard
search,
but since the names of the months have different lengths and May
consists
of
only three letters, siuch a search would find many other words
besides
the
names of the months. I therefore wrote the following macro which
searches
through the doc 12 times, but since it performs the searches on a
Range
object rather than the Selection object, it can do the work quickly
even
in a
large doc.

Sub FindMonths()
Dim monthArray As Variant
Dim myRange As Range
Dim i As Long

monthArray = Split("January,February,March,April,May," & _
"June,July,August,September,October,November,December",
",")
Set myRange = ActiveDocument.Range
With myRange
For i = 1 To 12
.Start = 0
Do While .Find.Execute(FindText:=monthArray(i - 1), _
Wrap:=wdFindStop, Forward:=True) = True
Select Case i
Case 1
' Replace the following line by the actions
' to be performed when January is found.
MsgBox "January found at " & .Start
Case 2
' Replace the following line by the actions
' to be performed when February is found.
MsgBox "February found at " & .Start
Case 3
' Replace the following line by the actions
' to be performed when March is found.
MsgBox "March found at " & .Start
Case 4
' Replace the following line by the actions
' to be performed when April is found.
MsgBox "April found at " & .Start
Case 5
' Replace the following line by the actions
' to be performed when May is found.
MsgBox "May found at " & .Start
Case 6
' Replace the following line by the actions
' to be performed when June is found.
MsgBox "June found at " & .Start
Case 7
' Replace the following line by the actions
' to be performed when July is found.
MsgBox "July found at " & .Start
Case 8
' Replace the following line by the actions
' to be performed when August is found.
MsgBox "August found at " & .Start
Case 9
' Replace the following line by the actions
' to be performed when September is found.
MsgBox "September found at " & .Start
Case 10
' Replace the following line by the actions
' to be performed when October is found.
MsgBox "October found at " & .Start
Case 11
' Replace the following line by the actions
' to be performed when November is found.
MsgBox "November found at " & .Start
Case 12
' Replace the following line by the actions
' to be performed when December is found.
MsgBox "December found at " & .Start
End Select
.MoveStart 1
.End = ActiveDocument.Range.End
Loop
Next
End With
Set myRange = Nothing
End Sub

--
Hope this helps,
Pesach Shelnitz


:

Is it possible to use the Find (Search) function to find either
January
or
February or March, etc, perhaps by using a macro? I would like
not
to
have to
use 12 different searches to search for the 12 months.
The action after having found a particular month varies; I
manually
apply an
action and then resume the search to the next incidence.
 

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