>I have several documents with several text lines beginning with date time
>string entries like:
[quoted text clipped - 14 lines]
>
>TIA
Like this:
Dim oRg As Range
Dim strTime As String
Dim lngSecs As Long
Set oRg = ActiveDocument.Range
With oRg.Find
.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "[0-9]{14}." ' 14 digits and a period
Do While .Execute
' skip the date part
oRg.MoveStart unit:=wdCharacter, Count:=8
' strip off the period
strTime = Left$(oRg.Text, 6)
' compute time in seconds
lngSecs = CLng(Right$(strTime, 2))
lngSecs = lngSecs + 60 * CLng(Mid$(strTime, 3, 2))
lngSecs = lngSecs + 3600 * CLng(Left$(strTime, 2))
' convert back to a 6-digit string plus period
oRg.Text = Format(lngSecs, "000000.")
' prepare for next find
oRg.Collapse wdCollapseEnd
Loop
End With
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Odie - 31 Mar 2005 14:25 GMT
Works perfectly Jay!! You rock -Thanks!!!! ;)
> >I have several documents with several text lines beginning with date time
> >string entries like:
[quoted text clipped - 50 lines]
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org