General macro for running other macros on batches of files?

N

Nomey

Hi There,

Does anyone know where I could find a snippet of code that executes another Sub in the same Module om a batch of Word files?

Or a macro that executes any other macro (user selected) on a batch of Word files?

Best regards,
Shirley
 
F

fumei via OfficeKB.com

As to the first question, you can execute another Sub by Calling it. In fact,
it is a good general idea to do exactly that. Break longish code into
multiple Subs, and Call them. The other Subs can have input arguments.

It is a good idea to do this, as it makes debugging chunks of code MUCH
easier. It also makes reading thing easier, as you are dealing with logical
chunks.

Sub DoLots()
Dim strIn As String
Dim oBM As Bookmark
' yadda yadda...some stuff
' giving value to the string
' setting a bookmark
' WHATEVER

Call DoOtherOne (strIn, oBM)
Call DoSomethingElse
End Sub

Sub DoOtherOne(strBlah As String, ThisBookmark As Bookmark)

' do something with strings and bookmarks

End Sub

Sub DoSomethingElse()

' lots of other crap
End Sub


As for question #2, user selected macros. You could certainly take a user
selected string, and make that a variable, then pass that to the Run method.

Look up the Run method in Help.:
 
F

fumei via OfficeKB.com

Sorry, but if you are asking HOW to execute action on a number of files, that
is a different thing.

Use the Dir function. It works well.
 

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