VBA to detect a Word doc using a macro in normal.dot


I have a tool built in Access that scans spreadsheets and Word for macros. Is working OK, except for the case of a Word Doc that has a macro that is stored in normal.dot.

Is their any detectable flag/object (using VBA) that would indicate this?

LVL 23
Kelvin SparksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
with reference to http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_25879769.html

What happens when you run your script specifying the normal.dot file?

You could include a scan for normal.dot files in your Word CheckWordForMacro function.  It could scan the users profile template directory: %USERPROFILE%/Application Data/Microsoft/Templates for the normal.dot
I think you have to check word instance to exist with your machine.
if word = nothing then
      msgbox "Install MS Word in your machine
end if
Kelvin SparksAuthor Commented:
We/re scanning remotely accross network shares. Won't have access to the local drives. More interested to know if there's something in a document that indicates that a template is/can be called.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

RobOwner (Aidellio)Commented:
My understanding is that if you open a word document it will load the normal.dot template of the user that is running the tool.  So if you run this tool on your computer then it would load the normal.dot from your computer. Make sense?
Kelvin SparksAuthor Commented:
Yes, I think it does (and any user level macros in their normal.dot will be unavailable)
RobOwner (Aidellio)Commented:
If you have profile set up for each user in a active directory domain then it will copy the normal.dot with the rest of the Roaming profile to the server where you could scan it?
Every document has an attached template.This is where any macros usually are. Less usually macros are in the document itself. The default template is the Normal template. Many users have macros there. Also there can be other global templates in the a user's Word Startup folder which contain macros. For this reason a document in one location can have access to macros that it doesn't have in another.

You can check  check the attached template property with


and test for global templates:

     For Each objAddIn In objWordApplication.AddIns
           MsgBox objAddIn.Name
      Next objAddIn


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
==>"...except for the case of a Word Doc that has a macro that is stored in normal.dot. "

A Word doc that has a macro that is stored in normal.dot doesn't actually have a macro in itself at all. A Word doc that doesn't have a specific Attached Template (see GrahamSkan's code, above) is attached to "normal.dot" by default, but that template will change depending on the user and the machine (except in the case of true Roaming Profiles, in which case it will stay with the user regardless of the machine).

It appears to me that your routine is working as designed. Normal.dot is loaded globally by default in Word, which means that any macros in Normal.dot are available to any documents that are open in that Word session. If you put another template containing macros in the Word startup folder, those macros will also be available to any document, exactly like those in Normal.dot.

I'm not convinced you actually have a problem, here.
Kelvin SparksAuthor Commented:
Than ks to all. Those last two have helped in my limited understand of Word immensely and tell me just what I need to know.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.