Copying references from template to documents

  • Thread starter Cameron Sutherland
  • Start date
C

Cameron Sutherland

I have a template with code that needs to connect to a
database (ADO) and to do this I need to add the object
library reference. The problem I'm faced with is in the
documents that are created from this tempalte are going to
be severed from the template so I copy all the code to
them locally except I can't figure out how to get the
reference to be copied over to the documents. I tried to
do it in code :
Application.VBE.ActiveVBProject.References.AddFromFile
strPath
but with some Microsoft security patch I get this
message: "Programmic Access to Visual Basic Project is not
trusted"
Is there some way to tell Word to copy references when it
creates the documents from the template?
-Cameron Sutherland
 
S

Shauna Kelly

Hi Cameron

Try Tools > Options > Security. Click Macro Security. On the Trusted
Publishers tab, tick "Trust access to Visual Basic Project".

If you have follow-up questions, I suggest you post to one of the Word VBA
newsgroups, such as microsoft.public.word.vba.general.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top