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.

Re: Macro on Folder and Subfolders by Jezebel

Jezebel
Thu Sep 22 03:19:23 CDT 2005

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.





"GTG" <gilleg@warringah.nsw.gov.au> wrote in message
news:1127372789.085546.22800@g43g2000cwa.googlegroups.com...
> 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.
>