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 / September 2005

Tip: Looking for answers? Try searching our database.

Macro on Folder and Subfolders

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GTG - 22 Sep 2005 08:06 GMT
Hi,

with the help of another post I am trying to combine two macros into
one to execute the macro on a folder of .doc files.

Here is my code that has a bug:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 22/09/2005 by Warringah Council for folder macro on
Position Descriptions

With Application.FileSearch
       .NewSearch
       .LookIn = "C:\Documents and Settings\gilleg\Desktop\testPDF\"
       .SearchSubFolders = True
       .FileName = "*.doc"
       If .Execute() > 0 Then
           For i = 1 To .FoundFiles.Count
   With Selection.Find
       .Text = _
           "<http://intra.warringah.nsw.gov.au/pdf/oh&s/GM
Ohsrprocedures201 OHSR Respon.pdf>"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute Replace:=wdReplaceAll
   With Selection.Find
       .Text = _
           "http://intra.warringah.nsw.gov.au/pdf/oh&s/GM
Ohsrprocedures201 OHSR Respon.pdf"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute Replace:=wdReplaceAll
   Selection.Paste

           Next i
       End If
   End With
End Sub

Thanks.
Jezebel - 22 Sep 2005 09:19 GMT
It's not so much a bug as a whole lot of missing code. FileSearch looks for
files and returns an array of filenames. It doesn't do anything with them.
You need to add code to open the file; then modify the search function to
look within the file (the Selection object is not what you want) then save
and close.

> Hi,
>
[quoted text clipped - 54 lines]
>
> Thanks.
 
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.