Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Running a function on created Global Template (Office 2003)

    Can anyone help (stupid question ... I'm sure there is someone that can help)? I have code stored in a global template that creates a toolbar. I have placed the template in the appropriate startup folder and checked that it is registered as an Add-In. Under "This Document" I have the code below (thinking that this will work) !!

    Private Sub Document_Open()
    CreateToolbarOnLoad
    End Sub

    Unfortunately the Sub does not get called, therefore the toolbar does not load.

    Any ideas?

    Many thanks
    Jack

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

    Re: Running a function on created Global Template (Office 2003)

    The Document_Open event procedure does not run because a global template is not opened as a document. Remove this procedure, and create a macro named AutoExec in a standard module:

    Sub AutoExec()
    CreateToolbarOnLoad
    End Sub

  3. #3
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running a function on created Global Template (Office 2003)

    Thank you Hans - You are a star.

    Regards
    Jack

  4. #4
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running a function on created Global Template (Office 2003)

    Afternoon Hans

    Could you help again .... please !!!

    The global template also has generic functions which I would like to call from other templates. One of the functions cycles through controls in a Userform. Is it possible to store the Userform in one template, eg Letter.dot, when that template runs the Letter.dot Userform shows and on "OK" it calls the "cycle through controls" function (passing in the userform) from the global template. To be honest, I'm not entirely sure whether this can be done.

    Hopefully I'm making sense.

    Many thanks
    Jack

  5. #5
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running a function on created Global Template (Office 2003)

    Afternoon Hans

    Problem is now solved in relation to running functions from a global template. For your information (just in case you're not aware).

    Open Template (in this case Letter.dot)
    In VBE go to Tools|References
    Select the GlobalTemplate (via the Project Name)

    That's basically it .... works amazingly well. I had been trying to do it through code - that's where I was going wrong.

    Regards
    Jack

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

    Re: Running a function on created Global Template (Office 2003)

    Thanks for sharing the solution. Should be useful for others encountering the same problem.

  7. #7
    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: Running a function on created Global Template (Office 2003)

    Setting a reference in the VB project associated with a particular template is one way. It is especially useful if you can't assume the global template already will be in memory. Other approaches include the Application.Run method (see <post#=335145>post 335145</post#> for more discussion).

Posting Permissions

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