简体   繁体   中英

How to save a word macro as an add-in

Trying to save a MS Word macro as an add-in, fully independent, portable and installable as a word tool. What kind of literature should I consult to learn this technique?

So far I've tried looking on Google and StackOverflow. Many people ask similar questions, no one seems to provide a valid answer.

In the end, I would like to be able to export a macro in the form of a exe/batch/whatever to be summoned/installed from word and customize the tools ribbon permanently, to conceal the macro sourcecode and easily propagate to other machines.

It's not possible to use VBA macros as exe or batch files. It is possible, however, to load a macro-enabled template as an add-in. All the functionality will then be available (Ribbon, keyboard shortcuts, macros, building blocks).

  1. Save the document as a dotm file (template, macro-enabled)
  2. Copy the file in the STARTUP folder. Word will then load it automatically.

For a "real" add-in that uses the same COM object model as VBA it's necessary to build software based on the IDTExtensibility2 interface. There are number of tools that use this, making things easier. Microsoft's VSTO (Visual Studio Tools for Office) is one that costs nothing.

Another alternative is to use the newer Java Script APIs for Office. These are, in the case of Word, incomplete as far as functionality for the object model is concerned (can't do everything the COM object model is capable of).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM