Advertisement

08.29.2007 at 09:01AM PDT, ID: 22794777
[x]
Attachment Details

How to run a macro on many word documens

Asked by PatternNut in Microsoft Word, Microsoft Office Suite, Visual Basic Programming

Tags: Visual Basic 6 / VBA

Hi Experts,

I have a long VBA macro I'd like to run on lots of Word documents all of which will be in one folder.  I want to set it up to run while I'm at work and when I return it will (hopefully) be finished.

At the moment my macro works when I'm in the document (ie I open the document, run the macro, save the revised document and then close it, open the next one, etc.).  

How can I make a second macro that handles all the opening, and closing bit, cycling through each in a folder?  It's hard to explain, but the syntax would be the equivalent instruction to something like:

for each file in directory X
   if it is a word document then
       open next file
       call long macro
       save that file
       close that file
   end if
next file

How on earth do I make it do that kind of cycle?  Thanks in advance for any ideas you have.

Cheers,

PatternNut

Start Free Trial
[+][-]08.29.2007 at 09:19AM PDT, ID: 19792778

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Word, Microsoft Office Suite, Visual Basic Programming
Tags: Visual Basic 6 / VBA
Sign Up Now!
Solution Provided By: matthewspatrick
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.02.2007 at 01:06PM PDT, ID: 19817939

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.08.2007 at 09:12AM PDT, ID: 19853704

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.08.2007 at 03:34PM PDT, ID: 19854703

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.08.2007 at 05:48PM PDT, ID: 19854952

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.10.2007 at 04:06PM PDT, ID: 19864925

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628