Run a macro from the Normal.dotm on all files from a folder

gailb
3StarLounger
Posts: 254
Joined: 09 May 2020, 14:00

Run a macro from the Normal.dotm on all files from a folder

Post by gailb »

I was helped with the link below earlier which works great.

https://eileenslounge.com/viewtopic.php ... fee1b000dc

Before I run the procedure in the Excel file from the above link, I open up each file and thru a button on the QAT (in the Word doc), I run a macro from the Normal.dotm. It would seem more efficient to run the macro from the Normal.dotm as this other macro is already opening all of the Word docs from the file.

The macro name is Sub CompleteTestMeasures

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Run a macro from the Normal.dotm on all files from a folder

Post by HansV »

I originally posted a macro in that thread that was intended to be run from Word. Doesn't that do what you want?
Best wishes,
Hans

gailb
3StarLounger
Posts: 254
Joined: 09 May 2020, 14:00

Re: Run a macro from the Normal.dotm on all files from a folder

Post by gailb »

Maybe I just don't see it or understand, but I still want to run the procedure from the Excel file, but as each Word file opens, can I run the macro from the Normal.dotm?

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Run a macro from the Normal.dotm on all files from a folder

Post by HansV »

Yes, use a line like this in the loop, after the Word document has been opened:

Code: Select all

        objWD.Run "MacroName"
where MacroName is the name of the macro that you want to run.

Alternatively, include the macro code in your Excel macro.
Best wishes,
Hans

gailb
3StarLounger
Posts: 254
Joined: 09 May 2020, 14:00

Re: Run a macro from the Normal.dotm on all files from a folder

Post by gailb »

Thank you Hans