dynamic creation of macros

J

Jan Kucera

Hi,
is it possible to generate (include) macros into the documents by code?
Version 2003, .net 2.

Thank you,
Jan
 
T

Tony Jollans

It is possible (see Document.VBProject and its various properties and
methods) but, to work, it requires that the user has "Trust access to Visual
Basic Project" set under Tools > Macro > Security.
 
C

Cindy M -WordMVP-

Hi Jan,
is it possible to generate (include) macros into the documents by code?
Version 2003, .net 2.
Yes...

If we're talking only Word 2003, then easiest would be to generate an XML
document.

If we're talking back to Word 2000, as mentioned in your other messages,
then it would have to be done using automation. Office provides the VBA
IDE extension object model (VBE) to manipulate VBA projects in Office
applications. In order to see some of this, start Word, press Alt+F11
(opens the VBA IDE).

Tools/References and activate a reference to the Microsoft Visual Basic
for Applications Extensibility library.

Press Ctrl+G (Immediate Window) and type:
ActiveDocument.VBProject

This property and everything you see in the Intellisense list belongs to
the VBE object model. Press F1 and the Help should open to this topic.
Through links and "See also" you can move to other topics. But the best
way to read the Help is to open the VBOB6.CHM file directly (Office 2003
has a lousy, lousy, lousy Help engine).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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