Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    From Global template call local custom dialog (Word 2002 XP SR3)

    I have local and global templates.

    One of my global templates is a custom interface, that stores custom menu items, toolbars and shortcut keys.

    In most local template there is code that calls a custom dialog. This dialog is custom and different for each local template eg
    localtemplate.main.Showdialog

    In my global userinterface template I would like to create a new shortcut key. Trap the shortcut key to run code to call and display the dialog boxes for the local templates.

    I worked out why in the global template there was never a shortcut key assigned to call the custom dialogs probaly because it was difficult to setup.

    As we have many local templates, I dont want to go into each local template and assign the shortcut keys to call the dialog.

    In my Global template is there a way I can do this?

    Would it go something like this....

    trap the shortcut key
    From the current active document, get the template(local) name
    If localTemplate.main.ShowDialog code exists then
    display the custom dialog
    else
    display warning message
    endif

    Or is there an easier way to do this?

    diana

  2. #2
    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: From Global template call local custom dialog

    I'm not sure that "localTemplate" can be a variable. How many templates do you have? If there are a reasonable number, you could use Select...End Select with hardcoded Application.Run statements for each template.

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: From Global template call local custom dialog

    True True

    The following works..
    Application.Run MacroName:="ShowDialog"

    However if the code doesnt exist, the code just aborts.

    Is there a test to see if the template has the code or module.
    as in testing if a bookmark exists eg...

    If ActiveDocument.Bookmarks.Exists("temp") = True Then
    ActiveDocument.Bookmarks("temp").Select
    End If

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

    Re: From Global template call local custom dialog

    You can use an error handler, like this:

    Sub Test()
    On Error GoTo ErrHandler
    Application.Run "ShowDialog"
    ...
    ...
    Exit Sub

    ErrHandler:
    MsgBox "Macro does not exist!", vbExclamation
    Resume Next
    End Sub

Posting Permissions

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