> Here is a short section of the text. The "....." indicates more text
> inbetween.
[quoted text clipped - 71 lines]
>>>>
>>>> Tery

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Russ this worked pretty well, but I had to change a few things and once I
did, it worked great. So here how I modified it so that I could get it to do
exactly what I wanted.
Sub Move_Running_To_Top()
Dim aRange As Word.Range
Dim aRange2 As Word.Range
'Set aRange = ActiveDocument.Content
'Set aRange2 = ActiveDocument.Range(0, 0)
Selection.find.ClearFormatting
With Selection.find
.text = "running"
.Replacement.text = "}"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.find.Execute
Selection.homekey Unit:=wdLine
With Selection.find
.MatchWildcards = True
.text = "Device[!^13]@running*\nend[^13 ]{1,}" 'space character included
While .Execute
Selection.Cut
Selection.homekey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Paste
Wend
End With
Selection.InsertAfter Chr(13)
Selection.InsertAfter Chr(13)
End Sub
I am now looking to do something else. I will start a new thread to work on
that one after, I look up to see if someone has talked about it.
> Harddrive747,
>
[quoted text clipped - 111 lines]
> >>>>
> >>>> Tery
Russ - 21 Nov 2007 20:54 GMT
Tery,
Glad you got it working.
Although, it seems curious that in your code you are changing the first
instance of the word 'running' to a '}' character?
And it looks like you didn't want to move the found text to the very
beginning of the document, but maybe after the first paragraph along with a
couple of empty paragraphs, afterwards, for spacing?
That is easily tweaked by using these changes:
'========================
Sub Move_Running_To_Top()
Dim aRange As Word.Range
Set aRange = ActiveDocument.Content
With aRange.Find
.Text = "Device[!^13]@running*\nend[^13 ]{1,}" 'space character included
.MatchWildcards = True
While .Execute
ActiveDocument.Paragraphs(1).Range.InsertAfter aRange.Text _
& vbCr & vbCr
aRange.Delete
Wend
End With
End Sub
'========================
To insert found text in the same order that it was found, I made this
adjustment:
'========================
Sub Move_Running_To_Top2()
Dim aRange As Word.Range
Dim aRange2 As Word.Range
Set aRange = ActiveDocument.Content
Set aRange2 = ActiveDocument.Paragraphs(1).Range
With aRange.Find
.Text = "Device[!^13]@running*\nend[^13 ]{1,}" 'space character included
.MatchWildcards = True
While .Execute
aRange2.InsertAfter aRange.Text & vbCr & vbCr
aRange2.Collapse direction:=wdCollapseEnd
aRange.Delete
Wend
End With
End Sub
'========================
I try to use the Range object, rather than the Selection object for speed.
So my code automatically moves everything to the top. Did you want to
**manually** select only certain devices that are running to move to the
top?
P.S.
I unintentionally left a \n in my original code posting because in MacWord I
have to use that instead of any ^13. So if it causes no problems in WinWord,
then ignore it, otherwise change the \n to a ^13 in the wildcard search
strings.
> Russ this worked pretty well, but I had to change a few things and once I
> did, it worked great. So here how I modified it so that I could get it to do
[quoted text clipped - 161 lines]
>>>>>>
>>>>>> Tery

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID