Macro on Folder and Subfolders

G

GTG

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.
 
J

Jezebel

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.
 

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

Top