find text and then copy all the paragraph before the text to a new file



I want a macro that finds a specified text to a brunch of word documents ,
and then copy talla the paragraphs (one or more) before this text to another
word file.

I have made the macro up to the point of opening all the docs from a
specified directory.

But i can't make it to the end.

Please if anyone knows.

The macro for open all the files one by one is:

Sub Macro1()

Dim strFile As String, strPath As String
Dim intCounter As Integer
Application.ScreenUpdating = False
strPath = "c:\dir1\"
strFile = Dir(strPath & "*.doc")
Do While strFile <> ""
ff = ff + 1
''Workbooks.Open strPath & strFile
On Error Resume Next
Documents.Open strPath & strFile, ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto


strFile = Dir()

End Sub



Word Heretic

G'day "gus" <[email protected]>,

Dir is a 'strange' command in the way it works. You have to call it
once and once only with your mask, then just call Dir with no parms to
get the next result from that mask. So you are endlessly processing
teh first file on your list with your current method of calling each
time with a parm.

Steve Hudson - Word Heretic

steve from (Email replies require payment)
Without prejudice

gus reckoned:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question