• Custom Toolbar in Protected Document (Word 2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Custom Toolbar in Protected Document (Word 2003)

    • This topic has 21 replies, 3 voices, and was last updated 18 years ago.
    Author
    Topic
    #440166

    Hi All!

    I’m having a heck of a time with a custom toolbar. If I open the template itself, it shows up just fine. But if I open the template as a document, my toolbar is nowhere to be found.

    I actually have two of these documents; the one that has no protection, which I created a while ago, works just fine. It’s the one with protection, which I just made, that loses its toolbar. I believe (although have no certain way of knowing) that I used the same approach for making both.

    Additional information: in the unprotected document, my “Update” toolbar is visible in both the template and the document in organizer view. In the protected document, the “Update” toolbar is available in the template, but it is not available in the document, in organizer view.

    How do I get the toolbar to be available to a specific template but also available when opened as a document?

    Any ideas?

    Thanks!

    Viewing 0 reply threads
    Author
    Replies
    • #1053778

      Open the template as a document and activate the Visual Basic Editor (Alt+F11).
      Check the ThisDocument module to see if there is a Document_New and/or Document_Open event procedure.
      Also check if there are modules under the Modules section, and if so, see if there is one containing an AutoNew or AutoOpen macro.
      There might be code that creates a toolbar on the fly – look for CommandBars.Add.
      Let us know what you find.

      • #1053780

        And I was so tempted to just address this post to Dear Hans! angel

        ThisDocument doesn’t contain anything. There are no Document_New or Document_Open event procedures.

        There is one module called basMain and it has one function called showMyForm and all it does is show the form in question.

        There isn’t any Commandbars_Add or anything of the sort.

        Putting the toolbar into the Normal.dot doesn’t help either, then I’m just always stuck with the toolbar, which I want only available when my template opens (and hopefully opens as a doc, not a template).

        Just for kicks, here’s a copy. The functionality of the form won’t work, but maybe you can see my toolbar problem?

        • #1053783

          Could you do the following:
          – Remove all text from the problem template.
          – Save it under another name (still as a template)
          – Zip the new template.
          – Attach the zip file to a reply.

          Added – oops, you already did that grin

          • #1053784

            LOL my psychic ability…

            I didn’t remove the text from the document, but I can do that if you’d like?

            • #1053787

              > I didn’t remove the text from the document, but I can do that if you’d like?

              No, that was just in case it contained sensitive info.

        • #1053786

          The problem is that this “template” is actually a document whose extension has been changed from .doc to .dot. This means that the template “framework” is missing. If you save the file from within Word as a template, that framework is added, and the toolbar will work as intended.

          • #1053789

            BRILLIANT.

            That’s what happens when we let the guys upstairs create our templates and then force us to use them. I did have a sneaking suspicion at one point about that but then forgot about it, ’cause the guy who did the template is a bigwig IT guy in that department.

            The lesson: NEVER trust other people’s templates.

            Please forgive me for deleting the attached file, but I think the description of what is wrong with it is enough for anyone to follow what happened.

            Would you mind deleting yours, too, Hans?

            Thanks!!!!

            trophy

            • #1053790

              OK, done.

            • #1053791

              I am still amazed and awed how I can agonize over something for more than a day, but for you it is a 5-minute fix. Or perhaps less.

              dizzy

            • #1053792

              I noticed that the Tools | Templates and Add-Ins… dialog showed the name of another template in the Document Template box near the top. For real templates, this box is empty and disabled.

            • #1054183

              Hey, Hans…If you happen to have a spare moment….another question, same form, probably similar problem….

              So I had two of these forms that pretty much do the same thing. One of them works perfectly fine. The other one, if I open it as a document and then save it and close it…then go back to open it again, it gives me the message “are you sure you want to open your WordTemplate.dot” and on closing, “do you want to save changes to your WordTemplate.dot” instead of wanting to save to the document.

              Is there possibly something else that is a bit bonkers in the form? What should I look for?

            • #1054195

              Let’s get the terminology straight.

              If you open a template, you’ll see the name of the template (AnnualAudit.dot) in the title bar. If you edit it then close it, you’ll be prompted to save changes to the template.

              If you create a new document from the template, you’ll see something like Document3 in the title bar, and if you edit then close it, you’ll be prompted to save changes in the document.

              If your macro security is set to Medium, you’ll be prompted to enable the macros in the template when you open the template or create a new document based on it, or open an existing document based on it, unless you have stored the template in your default templates folder and ticked the check box “Trust installed templates and add-ins” in the Trusted Sources tab of Tools | Macro | Security.

            • #1054196

              Exactly. I’ve got the terminology straight.

              What’s going on is I’m opening the template as a document from Access and saving it immediately in a predetermined folder with a predetermined name (made from Access data).

              The form that works properly, works properly, in that the predetermined name of the document shows up on the top of the document. When you close the form, if you’ve made no changes to the document, it closes with no fuss, and if you’ve made changes, it asks do you want to save the document.

              The form that works improperly (the attachment) DOES show the name of the document in the top, except during the Enable Macros portion, you are asked if you want to enable the macros from the .dot file. When you close the document, you are asked if you want to save changes to the .dot file.

              Does that make more sense?

              Edit: How do people attach screenshots to posts? I would post the screenshot if I could.

            • #1054198

              Do you use VBA code for “opening the template as a document from Access and saving it immediately”? If so, try using Documents.Add(templatename) instead of Documents.Open(templatename)

            • #1054199

              The Access Part:

              Here is what I’m using to create the document from the template:

              Set doc = .Documents.Add(strTemplate, , , True)

              this line follows immediately:

              doc.SaveAs strDocName

              In the case of re-opening the existing-made-from-template document (which is when I have the problem), I am using this line:

              Call Shell(“winword.exe ” & strDocName, vbMaximizedFocus)

              I am calling the same routines for opening both documents and just passing a different document or template name, so the fact that the behavior is different for the two different templates leads me to believe the problem is in the templates.

            • #1054201

              The line

              Set doc = .Documents.Add(strTemplate, , , True)

              does NOT open the template as a document. It creates a new document based on the template.

              If you still have the Word.Application object, you should not use Shell to start Word, but

              .Documents.Open(strDocName)

              Using that, I cannot reproduce the error using code from Access.

            • #1054202

              >>Set doc = .Documents.Add(strTemplate, , , True)

              does NOT open the template as a document. It creates a new document based on the template.<>If you still have the Word.Application object, you should not use Shell to start Word, but

              .Documents.Open(strDocName)<<

              Actually, the Word.application object is closed by then, and the user has come back to view the document he made previously. That's why I switched to shell.

              You don't need the Access portion to see this happen. Simply make a document based on the template and save it and close it. When you go back to open the document again, you'll get the message asking if you want to enable macros on the template, but the document name will properly appear at the top of the form. If you make a change in the form, upon closing you'll be prompted to save changes to the template.

              But I understand if you're busy….

              sorry

            • #1054206

              1) You kept on saying that you opened the template as a document. You weren’t, you were creating a new document based on the template. The latter is what you wanted, but it’s not what you repeatedly said.

              2) I’ve tried that too. The macro warning mentioning the template is normal – after all, the macros are stored in the template, not in the document. But I don’t get prompted to save the template when I close the document, either the first time after creating it or after reopening it later and editing it. So I’m afraid I cannot reproduce the problem. Are you sure you attached the template that causes the problem?

            • #1054242

              Sorry, I missed the nuance in what I was trying to say…you are right.

              The document that works doesn’t have the message about enabling macros in the template at all…so that’s still a difference.

              But if you don’t get the last one, where it asks if you want to save changes to the template, then it’s clearly my pc. Ugggh.

              I really do appreciate the help, and I will try to remember to say Open a new document based on a template. grin

            • #1054230

              Although the Shell is one way to open a Word document, you could try using automation instead. Not sure the results would be different, but they might, just as double-clicking in Windows Explorer sometimes give different results than using File>Open.

            • #1054244

              Thanks! I’ll change it to automation and see if it makes a difference.

    Viewing 0 reply threads
    Reply To: Custom Toolbar in Protected Document (Word 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: