Re: Macro Joy

Subject: Re: Macro Joy
From: "Edgar D' Souza" <edgar -dot- b -dot- dsouza -at- gmail -dot- com>
To: "Bonnie Granat" <bgranat -at- granatedit -dot- com>
Date: Tue, 9 May 2006 13:49:38 +0530

Well, maybe you don't need to go to Perl, Python or Ruby. After all,
they're just different programming languages, and you would be
exchanging a VBA learning curve for another language with no
appreciable advantage.

What I would do in this case is choose another component of Office to
host my macro - maybe Excel or Access. In either of those, you would
need to code the framework to get your "Accept Changes" instructions
to run against each doc in a folder. I'd do this thus (pseudocode):

- Create an instance of the Word application, which you will control
from this external code
- Get a list of doc files in the target folder (preferably using the
FileSystemObject object in the Microsoft Scripting Runtime library)
- Iterate over this collection of files
- For each file, issue commands to the Word application to open it and
accept all changes, save and close the doc.

To accomplish this, you will need to set references to the "Microsoft
Scripting Runtime" and "Microsoft Word 9.0 Object Library" libraries
(check the corresponding items in the list in the Tools..References
dialog in the VBA Editor)

Here's some sample code (not tested!) based on your setting the above

Sub ProcessDocsInFolder()
Dim objFSO As Scripting.FileSystemObject
Dim colFiles As Scripting.Files
Dim objFile As Scripting.File
Dim objWordApp As Word.Application
Dim objWordDoc As Word.Document

Set objWordApp = CreateObject("Word.Application")

Set objFSO = CreateObject("Scripting.FileSystemObject")
'Change the path in the following line to reflect the location of
the docs on your system.
Set colFiles = objFSO.GetFolder("C:\Docs\ToAccept").Files
'The folder can only have Word docs in it; no other file types!
For Each objFile In colFiles
Set objWordDoc = objWordApp.Documents.Open(objFile.Name)
objWordDoc.AcceptAllRevisions 'If you have any more/other code to
'accept changes, as recorded in your
'macro, replace it here...

'Cleanup - release created objects.
Set objWordDoc = Nothing
Set objWordApp = Nothing
Set colFiles = Nothing
Set objFSO = Nothing
End Sub

You can paste this code in the VB Editor in Access, after setting the
references I described above.
Lines beginning with a ' are comments and are not executed. Two of
those identify places which you may need to change.

Click inside the procedure (between the "Sub" and "End Sub" lines) and
hit F5 or click the Play button on the toolbar to run it. Let me know
if you have errors, with the exact description of same.

Disclaimer: this is untested code, offered for free. This is not
"professional" code, it does not have statements to handle errors in a
graceful manner. I'm not responsible if it chews up all your docs or
otherwise messes up. Make sure you have a backup of vital data, and
are running this on a COPY of the real folder containing the docs you
want processed. The statements in the procedure above are not going to
trash your machine unless there was something seriously wrong with it
anyway :-)


On 5/7/06, Bonnie Granat <bgranat -at- granatedit -dot- com> wrote:

According to the above site, what I want is not at all a simple thing. Oh,
well. I'm done with trying to use macros to process multiple files, unless
someone can correct any misconception I may have.

Bonnie Granat

I wrote (on the copyediting list):
> I have 246 files. I would like to accept all changes on all
> of them at one
> time and save them.
> I can create a macro to do that for each individual file, but
> I would like
> to know how to tell Word to go to one of the following:
> 1) The next open window/document.
> 2) The next document in a folder.
> I do not understand VBA at all and cannot find my way around
> the VBA Editor.
> Thanks to any and all who can help. Even if someone were to
> give me the text
> of a macro, I wouldn't know what to do with it to get it into Word.
> I may have to do all this by hand next weekend, but I'd
> rather not have to
> spend the time on it.

WebWorks ePublisher Pro for Word features support for every major Help
format plus PDF, HTML and more. Flexible, precise, and efficient content
delivery. Try it today!.

Doc-To-Help includes a one-click RoboHelp project converter. It's that easy. Watch the demo at

You are currently subscribed to TECHWR-L as archive -at- infoinfocus -dot- com -dot-
To unsubscribe send a blank email to
techwr-l-unsubscribe -at- lists -dot- techwr-l -dot- com
or visit

To subscribe, send a blank email to techwr-l-join -at- lists -dot- techwr-l -dot- com

Send administrative questions to lisa -at- techwr-l -dot- com -dot- Visit for more resources and info.


Re: Illustrator CS online help: From: Rick Stone
Macro Joy: From: Bonnie Granat

Previous by Author: Re: Localization Question
Next by Author: Re: Macro Joy
Previous by Thread: True Macro Joy Revealed!
Next by Thread: Re: Macro Joy

What this post helpful? Share it with friends and colleagues:

Sponsored Ads