How do I run a macro on multiple documents?

Using Run with Temporary Options

  1. Go to Macros | Run with Temporary Options….
  2. Choose the macro you want to run in the Macro field.
  3. Check Run the macro against each opened document. Click Add… to add files that the macro should be run on.
  4. Click Run.

Using Advanced Open

  1. Go to File | Advanced Open….
  2. Check Run the macro against each opened document. Click the “…” button to open the macro that you want to use.
  3. Click on Select Files to Open…. Select the files that the macro should be run on.

Using Scripting.FileSystemObject

  1. You can iterate through files in a folder with Scripting.FileSystemObject.
#language = "JScript"

function MyFunc( sFileName )   // macro function to call
{
    document.writeln( sFileName );  // Replace this with what you want to do with sFileName
}

var sFolder = "C:\\folder_with_files";   // a folder you want to search

var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFolder(sFolder);
var fc = new Enumerator(f.files);
for (; !fc.atEnd(); fc.moveNext()) {
    MyFunc( fc.item().name );
}