Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Mon, 19 May 2008 14:01:24 -0700 (PDT),    group: microsoft.public.word.vba.beginners        back       


Remove duplicate time entries   
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
date: Mon, 19 May 2008 14:01:24 -0700 (PDT)   author:   Spotty Boy

Re: Remove duplicate time entries   
Use:

   With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .MatchWildcards = True
        .Text = "(*^13)@"
        .Replacement.Text = "\1"
        .Forward = True
        .Wrap = wdFindContinue
        .Execute Replace:=wdReplaceAll
   End With


-- 
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

"Spotty Boy"  wrote in message 
news:ad27934e-e736-4137-a4dc-a59c9959c040@b1g2000hsg.googlegroups.com...
> 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
date: Tue, 20 May 2008 10:15:05 +1000   author:   Doug Robbins - Word MVP

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us