locked
tempate module lost from a document RRS feed

  • Question

  • Hi,

    I have a template which I call a Letter template. The template has some macros and a userform allowing users to fill out important fields for the letter they are about to generate. So when you run the template (.dot), a new word document is open and the userform pops up prompting users for filling out fields. When the users click OK, all the data in the text-box fields are put into the document (using the DOCVARIABLE). I also wrote macros that allow users to edit the letter in the future

    Anyway, the problem I am having is the template module in the document went missing. As far as I know, in VB editor, when a new document is generated from a template, you should see on the left hand panel - Normal, Project(mytestingletter) and the project module from the template that is attached to the document, and the macros will work because they exist. Yesterday, I tried to edit one of the letters that I generated from the template a while ago and I received an error message saying "The macro can not be found or has been disabled because of your macro security settings". The fact is the macro security has been enabled so I was thinking what went wrong. I open up the VB editor from the letter document, I realized that the project module for the template disappeared. That's why the macro did not work.

    My question is how would I put back the template module into the document. Note: the template was created using word 2003 but most users use word 2010 to run the template. I am not sure if this may be the reason for the deletion of the template module from a document.

    Any help would be greatly appreciated.

    Thank you

     

     


    Wednesday, May 25, 2011 11:48 PM

Answers

  • I think, perhaps, you are misunderstanding the way templates work.
     
    When you create a document from a template, that template becomes attached to the document. VBA code in the template stays in the template. When you save the document, Word saves details of the attached template with it.
     
    When you open the document, Word will also open the attached template - if it can. If Word can not open the template, it will temporarily attach the Normal template to the document. If your code is not visible in the VBE, it is because the template has not been opened, or because macros have not been enabled (but you say they have), or because the code has been deleted from the template (not the document - it was never in the document).
     
    It is probable that the template is not available for some reason.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Thursday, May 26, 2011 10:47 AM

All replies

  • I think, perhaps, you are misunderstanding the way templates work.
     
    When you create a document from a template, that template becomes attached to the document. VBA code in the template stays in the template. When you save the document, Word saves details of the attached template with it.
     
    When you open the document, Word will also open the attached template - if it can. If Word can not open the template, it will temporarily attach the Normal template to the document. If your code is not visible in the VBE, it is because the template has not been opened, or because macros have not been enabled (but you say they have), or because the code has been deleted from the template (not the document - it was never in the document).
     
    It is probable that the template is not available for some reason.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Thursday, May 26, 2011 10:47 AM
  • Hi,

     

    Since there is a period of time without any respond, I will  temporary mark the reply as answer to closed this thread.

    And if you come back to find it doesn't work for you, please reply to us and unmark the answer, this thread will be re-opened.

     

    Sincerely,
    Max Meng


    Sincerely,
    Max Meng


    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    Monday, June 6, 2011 6:24 AM