Deploying a VBA Macro

I have created a VBA macro that will be used by some text documents in my company. The macro detects tags and removes chapters from the document. This document is generated by another program. Thus, the macro must be separately distributed.

Is it possible to generate an executable that adds a macro to the user executing the executable?

Is there another way to batch macros and install them on the user's computer?

thank

+3


source to share


3 answers


Basically, there are five ways to do this:

1) Send each a text file with your own macro, which you can paste into your own Normal template. This is great for very simple macros that are unlikely to run into name collisions with macro users, but require a basic knowledge of the VB editor.

2) Send everyone the .bas file you create by exporting the module containing your macros. This gives you a little more control and avoids copy / paste errors. Still requires a basic understanding of the VB editor (or decent instructions from you).

3) Package your macros into a template (.dotm file) located in the Templates folder. Users can apply this template to any document they create and access your macros. Knowledge of VB is not required; this is done through the standard Word New File process. Also you can include styles or other things if you like.



4) Put your macros in the form of a global template (.dotm file), which is located in the "Startup" folder. Users will have access to your macros (s) in every file they work on, no template needed. This is fine if what you are doing is central to your team's workflow and does not require styles to be included in your macro. You can also create user interface elements. (Word 2011 might have problems with this approach; users might not have immediate access to the global template, but it's easy to get hold of.)

Both 3 and 4 require the user to place the .dotm file in the correct location first. You can help them with this (one approach is to use another Word document as the "setup" file, which, when run, places the template in the correct folder it is supposed to be). Obviously this requires more work on your part, so how much you would like to go with this is up to you and your business needs.

5) Also, if you have control over the creation of the document itself (not just the macro), you can embed the macro into the document. You can place the macro itself in the DocumentDocument module of the document (find your document in the Project Explorer and then open Microsoft Word Objects). Then save the document as .docm (Macro-Enabled Document). Users should be prompted to enable macros when opening a document (different versions of Word use slightly different interfaces to ask the user about this, but this is always pretty obvious).

+1


source


The easiest way to deploy macros is through a template. Create your macro and save the file as .dotm (macro-enabled template). I think you will get a suggestion on where to save your .dotm file.



Any coworker who wants to use your template just has to put it in that directory (I think it's C: \ Users \ [UserName] \ AppData \ Roaming \ Microsoft \ Templates). After that, he should be able to use macros while working on any text document.

+3


source


For the past 7 years, I have deployed my Word VBA in a different way. The software is a Word add-in that makes it easy for teachers to provide feedback on assignments. It is distributed as a 30-day trial and if the user purchases it, they are provided with a key that allows them to use the eMarking Assistant for a year. You can test the deployment system at http://eMarkingAssistant.com

The deployment and licensing mechanism is listed below:

  • save vba in a macro enabled document i.e. .docm file
  • on Windows, rename the file to a .doc file.
  • use Orlando's excellent "VBA decompiler and component" from http://orlando.mvps.org/VBADecompilerMore.asp to remove the compiled code and references to specific Office versions from the .doc and compact document
  • ask the user to download the .doc file
  • ask the user to open the .doc file and make sure macros are enabled.
  • allow user to trial software in document
  • if they want to use the software in any document, they click the "install" button in the document to copy the vba code into a .dotm file in their Word startup folder (so it is automatically downloaded).
  • if they want to buy a software subscription, they pay using paypal and I send them a key that unlocks the software until the end of the subscription

The advantages of this process:

  • one document can be used in all versions of Office for Windows from Office 97 to Office 2016 (32-bit and 64-bit).
  • installing and uninstalling everything happens inside Office, so suer doesn't need administrator rights on his computer.
  • users do not need to install software until they have used it in a document.
  • users do not need to use another program to unpack or install the software.

Peter Evans

+1


source







All Articles