none
Deploying VBA Word Application RRS feed

  • Question

  • Apologies in advance for asking such a basic question . . . 

    I've developed a custom Word template with an associated VBA project attached to it.  How do I deploy this such that the template is visible across our organization, but with the VBA project hidden so that users can't see/modify the code?


    DragonForest

    Tuesday, July 22, 2014 6:53 PM

Answers

  • Store the template in a shared network folder.

    Users can double-click the template to create a new document from it.

    To set a password on the VBA code:

    - Press Alt+F11 to activate the Visual Basic Editor.
    - Select Tools | VBAProject Properties...
    - Activate the Protection tab.
    - Tick the check box "Lock project for viewing".
    - Enter the password in both boxes. Do not forget this password!
    - Click OK.
    - Save the workbook.

    Next time you open the workbook, you'll need the password to view the code in it. Users who don't know the password will not be able to view the code.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by DragonForest Tuesday, July 22, 2014 10:26 PM
    Tuesday, July 22, 2014 7:09 PM

All replies

  • Hello Dragon,

    VBA code is not designed for deployment on multiple PCs. Instead, I'd recommend developing an add-in. That's exactly what they were designed for.

    Tuesday, July 22, 2014 7:08 PM
  • Store the template in a shared network folder.

    Users can double-click the template to create a new document from it.

    To set a password on the VBA code:

    - Press Alt+F11 to activate the Visual Basic Editor.
    - Select Tools | VBAProject Properties...
    - Activate the Protection tab.
    - Tick the check box "Lock project for viewing".
    - Enter the password in both boxes. Do not forget this password!
    - Click OK.
    - Save the workbook.

    Next time you open the workbook, you'll need the password to view the code in it. Users who don't know the password will not be able to view the code.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by DragonForest Tuesday, July 22, 2014 10:26 PM
    Tuesday, July 22, 2014 7:09 PM
  • Many  thanks, Hans and Eugene. 

    If one takes the Add-in route (I assume this means saving as an .xlsa file) how is this deployed across the organization?


    DragonForest

    Tuesday, July 22, 2014 10:29 PM
  • Everyone will have to install the add-in (.dotm for Word, not .xlsa) in their WORDSTART folder.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)


    Wednesday, July 23, 2014 5:34 AM
  • Hi DragonForest

    What you should use depends on a number of factors:

    1. Is the code related directly to a specific (type of) document? If yes, then template approach discussed in the first part of this exchange is the appropriate way to procede. The users will create new documents of this type from the template and the code will be associated only with these documents.

    2. Is the code something that should be available no matter what kind of document the user is editing? Then the Add-in approach is more appropriate.

    There are basically two kinds of add-ins: the template kind that Hans is assuming and a COM add-in, which is what Eugene means. You cannot use VBA for the latter; it would require you to (a) learn a .NET language and (b) own an edition of Visual Studio that provides Visual Studio Tools for Office.

    If the Add-in approach using a template is the better one for your code, and the code should be distributed in a networked company, then IT can use a Group Policy to distribute it to the users' Startup folder, rather than each user needing to copy it to the folder themselves. If you later need to update the code a Group Policy would also be the right way to replace the existing template with the new version.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, July 23, 2014 3:27 PM
    Moderator