Run macro upon all files within a folder

R

RPMitchal

Word 2007

Dear Gurus:

I am attempting to find a macro that would possibly run an already existing
macro upon all files within a specific folder.

For example: I need to convert all existing styles within a series of
resumes to styles newly created in a template by someone else.

I have created the macro that will make the style conversions, but I am
further in need of a process by which this macro can be automatically applied
to all files within a given folder.

Any assistance in this regard will be greatly appreciated.

Thanks - Rod
 
R

RPMitchal

Hello Dave:

Thanks so much for your quick and helpful response. I had previously
checked out and actually made use of the link to which you directed me. My
problem seems to be that I remain perplexed by VBA.

I would have no idea how to modify the coding so that I could incorporate an
existing macro instead of using the *find and replace* feature.

If you are able to shed any further light on the subject or the necessary
modifications I would need to make, I would continue to be very appreciative.


Thanks Again - Rod
 
F

Fumei2 via OfficeKB.com

Sub TheStuffToDo()
' the coding to do the processing on each opened file
' yadda yadda
' yadda yadda
End Sub

Sub DoItNow()
Dim file
Dim path As String

' the path to the folder
' make SURE you include the terminating "\"
Path = "c:\yadda\whatever\"

file = Dir(path & "*.doc")
Do While file <> ""
Documents.Open Filename:=path & file
' call to macro that does whatever
' one would assume it is using ActiveDocument!
CALL TheStuffToDo
' assuming you want to save the current file
ActiveDocument.Save
ActiveDocument.Close
' set file to next in Dir
file = Dir()
Loop
End Sub

In other words, use Dir to GET each file, and then CALL to the macro you
already have to do the actions.
 
R

RPMitchal

Fumei:

Thanks so much. I can't tell you just how much I appreciate the assistance
and feedback that I receive from the Forum.

Rod
 

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