Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Attached template deleting add-in (Word 2003)

    For each file that I open at work, I have to attach the proper custom template to it. After the template is attached, regardless of which template it is, I do the same things: Add a slug line, pull up the Reviewing toolbar, turn on track changes, etc.

    I've created a macro that runs through a series of other short macros to automate all of the repetitive bits. It starts by invoking

    Application.Dialogs(wdDialogToolsTemplates).Show

    I then choose the template that I want and click OK. It then goes on to complete the process by running both macros in the same module and macros in the template that was attached.

    I have this all saved in my Normal template, and it works beautifully and saves me lots of time. I decided not to hoard it, so I saved it all in a separate template that I sent out to my other coworkers.

    So I have an AndysEditingCode.dot file that I've sent to my coworkers. Here's the problem:

    I've told them to open the Templates and Add-ins dialog box and add this template to the Add-ins section (the bottom half of the dialog box) and make sure that it's check-marked. The toolbar that I added to the file then appears as it should.

    When they run the macro in question (PrepChapter), the Templates and Add-ins dialog box appears (as it should), but:
    1) The AndysEditingCode.dot file doesn't appear in the Add-ins section of that dialog box.
    2) All of the controls in the Add-ins section are deactivated and unavailable.
    3) After they load in the correct template, the link to the AndysEditingCode.dot template breaks, so that the rest of the string of macros don't run (and all of the other tools are gone, too).

    After trying to run this, when I go back to the Templates and Add-ins dialog box, the AndysEditingCode.dot file still appears in the Add-ins section, but it isn't selected. Basically, through the course of running the macro, the template turns itself off.

    I want to avoid having my coworkers import these modules into their own Normal.dot templates because it'll be a pain in the but to update, it's too easy for others to screw up, and I don't want to risk ending up in a meeting with IT and HR. What help can you offer?

    If my explanation isn't clear enough, I can post the code itself...but hopefully it won't be necessary.

    Thanks.

  2. #2
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Attached template deleting add-in (Word 2003)

    Welcome to the Lounge Andrew
    If you want a file to be available as a global template, save it in the Word Startup folder. Each user can identify their specific location through Tools | Options | File Locations . It is usually found at Cocuments and Settings[User]Application DataMicrosoftWord|Startup.
    Regards
    Don

  3. #3
    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: Attached template deleting add-in (Word 2003)

    I noticed the "missing" add-ins section when automating the Templates dialog, and I didn't notice the ill effect of then unloading the add-ins. (This is in Word 2002, I guess Word 2003 works the same way.)

    Perhaps it would be better to use your own dialog to get the desired template. If you have a Word 2002-2003 environment, you can use the FileDialog collection which lets you customize the title bar and, I assume, the filter (.DOT). You then can change the ActiveDocument.AttachedTemplate in code and bypass the Templates dialog.

  4. #4
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Attached template deleting add-in (Word 2003)

    I tried putting it in the Startup folder but had the same problem. The add-in disappeared halfway through execution.
    If it helps (maybe there's a glaring error I'm missing?), here's the code:
    <pre>Sub PrepChapter()
    Application.Dialogs(wdDialogToolsTemplates).Show
    Application.Run "NewMacros.PageBorders"
    Application.Run "DummiesMarginSet.DummiesMarginSet"
    Selection.Sections(1).Footers(1).PageNumbers.Add PageNumberAlignment:= _
    wdAlignPageNumberRight, FirstPage:=True
    ActiveWindow.ActivePane.View.Type = wdNormalView
    'Percent135
    ActiveDocument.TrackRevisions = True
    CommandBars("Reviewing").Visible = True
    n = MsgBox("Add a slugline?", vbYesNo, "Slugline")
    If n = vbYes Then Call slugline Else: Exit Sub

    End Sub
    </pre>

    The two macros in the third and fourth lines are modules.macros that appear in all versions of the templates. The "slugline" macro at the end appears in the same module as the PrepChapter macro.

    I tried going through Application.Dialogs(wdDialogsFileOpen) [or something to that effect] to pull out the name of the template, but then I couldn't figure out how to assign the choice to ActiveDocument.AttachedTemplate, so maybe a little help there? If you had intended something else with the bit about using "FileDialog" -- which you probably did -- it's probably beyond my abilities.

    EEK!

  5. #5
    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: Attached template deleting add-in (Word 2003)

    FileDialog is an Office-wide object, not part of Application.WordObjects, so it might not be apparent how to get to the help screens. However, if you type FileDialog( you will find an option with a name similar to "file picker" that you can use to fetch the name of a file. For more details, highlight FileDialog and press F1. (Sorry, I don't have any code samples handy. You also could search on this board.)

Posting Permissions

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