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 / November 2007

Tip: Looking for answers? Try searching our database.

General macro for running other macros on batches of files?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nomey - 29 Nov 2007 15:23 GMT
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
fumei - 29 Nov 2007 18:14 GMT
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.:

>Hi There,
>
[quoted text clipped - 4 lines]
>Best regards,
>Shirley
fumei - 29 Nov 2007 18:15 GMT
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.

Rate this thread:






 
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.