Link to home
Start Free TrialLog in
Avatar of TimLitle
TimLitle

asked on

How do I programatically make "Microsoft Visual Basic for 5.3" a Word VBE Reference?

I thought the statement

VBE.ActiveVBProject.References.AddFromFile ("C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL")

would do it but apparently not.  What did I do wrong?
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Why would you want to do that? It should already be referenced.
Avatar of TimLitle
TimLitle

ASKER

Your question is a good one because the statement should have been:

     "VBE.ActiveVBProject.References.AddFromFile ("C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB")"

What I was trying to do is programmatically create a new .docm file, copy code modules to it, and because the copied code modules require it, I need to have the following Available Reference checked:

     "Microsoft Visual Basic for Applications Extensibility 5.3"

For some reason, if I can't save a .docm file with Extensibility 5.3 checked and then open it with Extensibility still checked.  However, if immediately after programitically opening the .docm file, I run the "VBE6EXT.OLB" statement, then copy code modules to it, then save it, the Extensibility 5.3 check survives.

I guess my only question at this point is why does the first sentence of the immediately above paragraph behave the way it does?

ASKER CERTIFIED SOLUTION
Avatar of TimLitle
TimLitle

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial