Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    template changes (Word XP/2000/97)

    Hi,

    I have a template with a simple macro in NewMacros that enables/disables File|Page Setup & File|Properties menu items and is accessed using
    the keyboard shortcut Shift-Alt-Ctrl+Z. The macro is as follows:

    Sub NEWAllowAccessToMenuAndHeaders()
    '
    ' AllowAccessToMenuAndHeaders
    '
    Dim iFileSaved As Long

    iFileSaved = ActiveDocument.Saved
    CommandBars("File").FindControl(ID:=750).Enabled = Not (CommandBars("File").FindControl(ID:=750).Enabled)
    CommandBars("File").FindControl(ID:=247).Enabled = Not (CommandBars("File").FindControl(ID:=247).Enabled)
    ActiveDocument.Saved = iFileSaved
    End Sub

    I open a document and press Shift-Alt-Ctrl-Z to switch on the menu options. When I try to close the file (no changes to the file), it asks me if I want to save the changes to the template as well. I don't understand where I am changing the template. It is not important to fix this issue as I can live with it but is quite annoying. Any ideas?

    Thanks in advance.

    Robie.
    Thanks.
    Robie

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: template changes (Word XP/2000/97)

    Customizations to menus and toolbars are stored in the template attached to the document, not in the document itself, so if you disable or enable menu items, you are modifying the template. You can check this as follows:
    - Open a document based on the template, or create a new one.
    - Disable the menu items.
    - Close the document.
    - Reply Yes to the prompt to save the template (you don't have to save the document).
    - Create a new document based on the template.
    The menu items will be disabled!

    You can get around this by applying your code to set/restore the Saved status to ActiveDocument.AttachedTemplate instead of to ActiveDocument.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: template changes (Word XP/2000/97)

    Thanks a bunch. That is just what I was looking for. My hats off to you.

    I don't what I would do without guys like you & Andrew, JScher and others (whose names I forget).

    Thanks.
    Thanks.
    Robie

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: template changes (Word XP/2000/97)

    Word allows you to set a CustomizationContext that, according to the documentation, should allow you to apply commandbar changes to a single document. If you search for customizationcontext in help, you can read up on it. In your code, you might simply try adding

    CustomizationContext = ActiveDocument

    before you change the commandbars. Does this work around the default behavior?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •