S
Spotty Boy
Hi,
I am trying to replace a particular string in a simple file and cannot
seem to get it to work. There are no errors but all the time entries
are replaced. Ultimately, I want to delete only the redundant time
entries. This is a MS Word 2003 VB Macro. I've seen so much
contradictory junk that I'm lost and the MS documentation is certainly
no help ... Thanks in advance for any ideas ...
EXAMPLE FILE:
MONDAY
00:00
01:01
TUESDAY
03:24
03:24
03:28
WEDNESDAY
04:12
04:13
07:23
THURSDAY
00:30
00:30
CODE:
Sub deltime()
'
' test5 Macro to Delete redundant time entries
Selection.Find.MatchWildcards = True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
'
With Selection.Find
.Text = "[0-9][0-9]:[0-9][0-9]"
.Forward = True
.Wrap = wdFindContinue
If Selection.Text = "03:24" Then
Selection.Find.Replacement.Text = "ABC"
End With
'
Selection.Find.Execute Replace:=wdReplaceAll
'
End Sub
I am trying to replace a particular string in a simple file and cannot
seem to get it to work. There are no errors but all the time entries
are replaced. Ultimately, I want to delete only the redundant time
entries. This is a MS Word 2003 VB Macro. I've seen so much
contradictory junk that I'm lost and the MS documentation is certainly
no help ... Thanks in advance for any ideas ...
EXAMPLE FILE:
MONDAY
00:00
01:01
TUESDAY
03:24
03:24
03:28
WEDNESDAY
04:12
04:13
07:23
THURSDAY
00:30
00:30
CODE:
Sub deltime()
'
' test5 Macro to Delete redundant time entries
Selection.Find.MatchWildcards = True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
'
With Selection.Find
.Text = "[0-9][0-9]:[0-9][0-9]"
.Forward = True
.Wrap = wdFindContinue
If Selection.Text = "03:24" Then
Selection.Find.Replacement.Text = "ABC"
End With
'
Selection.Find.Execute Replace:=wdReplaceAll
'
End Sub