Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gus - 11 Jul 2005 00:13 GMT
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()
   Loop

End Sub
Word Heretic - 11 Jul 2005 08:41 GMT
G'day "gus" <gus@otenet.gr>,

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 wordheretic.com (Email replies require payment)
Without prejudice

gus reckoned:

>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
[quoted text clipped - 33 lines]
>
>End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.