none
VBA Compile Error RRS feed

  • Question

  • Hi all,

    I have an issue that I have been unable to resolve.  I have a Word 2010 document (a .docm) that I have created as a template for other users containing edit boxes, drop down lists etc and buttons to save the documents with a specific name in a certain place.  The save buttons have VBA code behind them.  This works exactly as I want it on my laptop BUT, when I save it as a .dotm the drop down lists and edit boxes DO NOT allow editing.  So I continued using the .docm as a template BUT when another user attempts to save using the button an error is provided stating "Compile error: can't find project or library". Its as if the VBA components are not there when another person runs it.

    What is wrong here please?

    Wednesday, October 25, 2017 9:30 AM

All replies

  • Regarding the template issue, you should check whether any of the code references 'ThisDocument' instead of 'ActiveDocument', as the former will reference the controls in the template, not the document created from it.

    As for the compile error, if the other user is using an earlier version of Office and your project references any later libraries, they won't be found on the other system. In that case, you'll need to modify the code to use late binding or compile it on a system using the oldest Word version you want it to run on. Another possibility is that the other user's Office installation is faulty, in which case a repair should resolve the issue.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Wednesday, October 25, 2017 11:14 AM
  • Hi Paul Edstein, thanks for the response.  I have had to step back and just go with a very basic template because I cannot spend much more time on this.  However, I am finding that even with a new template created from a blank document with some edit boxes for input only and the restriction set to "fill as form" - no VBA or macros.  Then I open a new document from the template the edit boxes are not active, they just say the instruction text and don't allow to be clicked on.  Why is this happening please?

    • Edited by alanjo Wednesday, October 25, 2017 4:15 PM
    Wednesday, October 25, 2017 4:14 PM
  • Probably because you haven't actually applied the 'filling in forms' protection; either that or you're using a mix of content controls and formfields but you've then saved the document in the older .doc format - which doesn't support content controls.

    Do note that you shouldn't use content controls and formfields in the same document. They weren't designed to be used that way and using both can lead to inconsistent behaviour.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Wednesday, October 25, 2017 8:22 PM
  • Hello,

    >>However, I am finding that even with a new template created from a blank document with some edit boxes for input only and the restriction set to "fill as form" - no VBA or macros. 

    As the issue is not related to Word Object Model, I suggest you post on Word IT Pro Discussions forum. You may share detail repro steps or a sample file, so that others could reproduce your issue and find the cause and solution.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 30, 2017 7:17 AM
    Moderator