A
avkokin
Hello.
There is a document which has some text (copy from forums) and some
areas as like: "send 18:05 23.08.08". I need to extract all such areas
to new document without of text "send".
I tried use next code (below), but it cycled.
My code:
Sub extractDateTime()
Dim dt As String
Dim oRange As Range
Dim newDoc As Document
Dim actDoc As Document
Set actDoc = ActiveDocument
Set oRange = actDoc.Range
Set newDoc = Documents.Add
actDoc.Activate
Selection.HomeKey wdStory
With Selection.Find
.ClearFormatting
.Forward = True
.Wrap = wdFindStop
.Text = "send ([0-9]{1;}:[0-9]{1;} [0-9]{1;}.[0-9]{1;}.[0-9]{1;})"
.Execute
While .Found
dt = Selection.Text
newDoc.Activate
InsertAfter dt & vbCr
Wend
End With
End Sub
I know that I have the bad logic. But I want to ask for you: where is
my error?
Thank you very much.
There is a document which has some text (copy from forums) and some
areas as like: "send 18:05 23.08.08". I need to extract all such areas
to new document without of text "send".
I tried use next code (below), but it cycled.
My code:
Sub extractDateTime()
Dim dt As String
Dim oRange As Range
Dim newDoc As Document
Dim actDoc As Document
Set actDoc = ActiveDocument
Set oRange = actDoc.Range
Set newDoc = Documents.Add
actDoc.Activate
Selection.HomeKey wdStory
With Selection.Find
.ClearFormatting
.Forward = True
.Wrap = wdFindStop
.Text = "send ([0-9]{1;}:[0-9]{1;} [0-9]{1;}.[0-9]{1;}.[0-9]{1;})"
.Execute
While .Found
dt = Selection.Text
newDoc.Activate
InsertAfter dt & vbCr
Wend
End With
End Sub
I know that I have the bad logic. But I want to ask for you: where is
my error?
Thank you very much.