问题
I have a macro that I developed in Word 2010.
How do I send this to others to use?
回答1:
Save the document as .dotm (macro enabled template). Save it to
%Appdata%/Microsoft/word/startup
Close word. Now, it will be accessible to all other word documents.
If not by default, then go to templates and tick the file saved above
to deploy, create a simple script that copies the file to the appropriate folder. You can probably deploy via email
回答2:
From the sublime to the ridiculous, here are four different options:
- Create an add-in. Distribute and tell others to install it. Instructions
- Create a COM add-in. Distribute and tell others to set a reference to it. Instructions
- Export the code module containing your macro to a *.bas file. (Right-click module, Export File...) Distribute and tell others to import it.
- Copy-paste macro code into an e-mail. Distribute and tell others to paste it into a module.
回答3:
- Go to the VBA Editor.
- Open the Project Explorer if it is not visible (
View>ProjectExplorer
orCtrl+R
). - If a new module is needed in the project for your file (
Project ( _your file_ )
),- right click on the project and select
Insert>Module
- OR select the project, then on the menu, select
Insert>Module
.
- right click on the project and select
- In the Project Explorer, open Project ( your file )>Modules>ModuleX.
- Copy your code into this module.
- Save the file as a
Word Macro-Enabled Document (*.docm)
(File>Save
orCtrl+S
). - Distribute the file. The code will now go with it.
回答4:
I used an old solution - Nullsoft Scriptable Install System to copy the .dotm file to the %Appdata%/Microsoft/word/startup
directory. To do this, I set InstallDir in the NSIS script to this:
InstallDir "$APPDATA\Microsoft\Word\Startup"
NSIS creates a small installer in the form of an EXE file that is easy to distribute and easy for users to install.
来源:https://stackoverflow.com/questions/9384802/how-to-deploy-word-2010-macros-to-others