S
sean
Hi All.
Thanks for all the previous help. Now for my next problem.
Synopsis: I have a find that searches a range. The range is the whole
document at the start. I have a find statement that searches for text at
the beginning of the line until the next occurrence of the simular text at
the next paragraph. There is always several paragraphs between the start
and end of the find range. The problem is that I don't want to include the
text at the end of the find. Lets use the following example text:
*** example starts ***
document.zip - a document
description of document.
document2.zip document two
description of text
document3.zip - document 3.
etc.
*** example ends ***
I only want to have the document 1 paragraph and the description of the
document in the range, nothing else. Then when the find starts again, it
has to start before the document2 paragraph. I am skipping the second
document and starting the third document. I know that I am screwing up the
ranges again. Code below:
Sub ConvertFile()
Dim oDocument As Document
Dim oRange As Range
Dim sDocumentName As String
sDocumentName = ActiveDocument.Name
Set oDocument = Documents(sDocumentName)
Set oRange = oDocument.Range
With oRange.Find
.Forward = True
.ClearFormatting
.Format = False
.MatchAllWordForms = False
.MatchCase = False
.MatchSoundsLike = False
.MatchWholeWord = False
.MatchWildcards = True
.Text = "^13[! ]@.ZIP*^13[! ]@.ZIP"
Do While .Execute
' moves the range to the beginning of the previous paragraph
oRange.MoveEnd Unit:=wdParagraph, Count:=-1
' removes any paragraph mark at the beginning of range.
oRange.MoveStart Unit:=wdParagraph
oRange.Move Unit:=wdParagraph, Count:=2
oRange.Collapse Direction:=wdCollapseEnd
MsgBox oRange.Text
Loop
End With
End Sub
Please help in straitening out the code above.
Regards
Sean
Thanks for all the previous help. Now for my next problem.
Synopsis: I have a find that searches a range. The range is the whole
document at the start. I have a find statement that searches for text at
the beginning of the line until the next occurrence of the simular text at
the next paragraph. There is always several paragraphs between the start
and end of the find range. The problem is that I don't want to include the
text at the end of the find. Lets use the following example text:
*** example starts ***
document.zip - a document
description of document.
document2.zip document two
description of text
document3.zip - document 3.
etc.
*** example ends ***
I only want to have the document 1 paragraph and the description of the
document in the range, nothing else. Then when the find starts again, it
has to start before the document2 paragraph. I am skipping the second
document and starting the third document. I know that I am screwing up the
ranges again. Code below:
Sub ConvertFile()
Dim oDocument As Document
Dim oRange As Range
Dim sDocumentName As String
sDocumentName = ActiveDocument.Name
Set oDocument = Documents(sDocumentName)
Set oRange = oDocument.Range
With oRange.Find
.Forward = True
.ClearFormatting
.Format = False
.MatchAllWordForms = False
.MatchCase = False
.MatchSoundsLike = False
.MatchWholeWord = False
.MatchWildcards = True
.Text = "^13[! ]@.ZIP*^13[! ]@.ZIP"
Do While .Execute
' moves the range to the beginning of the previous paragraph
oRange.MoveEnd Unit:=wdParagraph, Count:=-1
' removes any paragraph mark at the beginning of range.
oRange.MoveStart Unit:=wdParagraph
oRange.Move Unit:=wdParagraph, Count:=2
oRange.Collapse Direction:=wdCollapseEnd
MsgBox oRange.Text
Loop
End With
End Sub
Please help in straitening out the code above.
Regards
Sean