Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    New menu item (2003)

    I have been unable to find what I seek in this forum.

    I have a number of templates I have designed that are sort of

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

    Re: New menu item (2003)

    I know this is not what you asked, but you can get the Templates dialog in one click:
    - Select Tools | Customize...
    - Activate the Commands tab.
    - Select "All commands" in the list of Categories.
    - Select FileNewDialog in the list of Commands.
    - Drag this item to a convenient location on a toolbar.
    - Right-click the new item and change its name from Other... to New...
    - Press Enter, then close the Customize dialog.

  3. #3
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New menu item (2003)

    Close enough! Thanks Hans

  4. #4
    Bronze Lounger IanWilson's Avatar
    Join Date
    Dec 2000
    Location
    Bristol, United Kingdom
    Posts
    1,523
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: New menu item (2003)

    You could do it like this. A bit of a palaver to set up but a time saver in the end. Record a macro for each template you want to be able to access more quickly. So go to Tools | Macro | Record new macro... You have to give it a name (say Datelist for your Datelist.dot template, or whatever). Then go through the motions to create a new document from the template concerned (Click on File | New, select the template you want in the panel on the right) and once the new document has opened click the stop button on the floating macro tool bar. Do the same for the other templates you want to have quick access to.

    Now create a new menu by clicking on Tools | Customize... , choose the commands tab and scroll down to the bottom of the list to find new menu. You can drag the 'New Menu' from the right hand pane up to the menu bar then right click it and change its name to Create, or Templates or whatever you like. With the customize dialog still open find macros on the list on the left and click it. The macros you just recorded should appear in the list on the right, and you can drag each of them to the new menu, then close the customize dialog.

    Alternatively, you can use a similar approach to add buttons to a tool bar for frequently used templates.

    Hope that helps.

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

    Re: New menu item (2003)

    Your approach will work, but it will result in a static menu.

    From Don's remark "Obviously, it would have to display only what is in the workgroup template folder taking into account recent additions/deletions", I surmised that he wanted the menu to be dynamic, i.e. it should automatically expand/contract as templates are added/removed. You'd need code in the AutoExec macro in Normal.dot (or in a global template) to read the user templates folder and create the menu from scratch each time Word is started.

  6. #6
    Bronze Lounger IanWilson's Avatar
    Join Date
    Dec 2000
    Location
    Bristol, United Kingdom
    Posts
    1,523
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: New menu item (2003)

    <hr>You'd need code in the AutoExec macro in Normal.dot (or in a global template) to read the user templates folder and create the menu from scratch each time Word is started.
    <hr>
    Beyond my level of expertise, Hans!

    Ian

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

    Re: New menu item (2003)

    I was too lazy to write it, so I suggested something else... <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

  8. #8
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New menu item (2003)

    Can you believe it?! I HAD to do it, but was out all night so its a little late!

    It reminded me of something I wanted to do a while ago when I was contantly opening the same documents as part of my work... post <!post=369950 ,369950 >369950 <!/post>

    If you open WORD and go to the VB editor - ALT + F11, then on the left, click 'Normal' in the project explorer, 'Microsoft Word Objects', then 'ThisDocument'.

    Paste the following code into the Editor under 'General' and save it.

    <font color=blue>

    Sub AutoExec()
    Dim cmdBr As CommandBar, cbC As CommandBarControl, c As CommandBarButton
    Dim strPath As String, strTemp As String

    Set cmdBr = Word.CommandBars("Menu Bar")

    'remove old CREATE Menubar
    For Each cbC In cmdBr.Controls
    If cbC.Caption = "CREATE" Then
    cbC.Delete
    End If
    Next cbC

    'Make CREATE menu
    Set cbC = cmdBr.Controls.Add(msoControlPopup)
    cbC.Caption = "CREATE"
    cbC.BeginGroup = True

    'Add template names to popup menu
    strPath = Word.Options.DefaultFilePath(wdWorkgroupTemplatesP ath) & ""
    strTemp = Dir(strPath)
    Do While strTemp <> ""
    'check for template extension
    If Right(strTemp, 4) = ".dot" Then
    Set c = cbC.Controls.Add(msoControlButton)
    With c
    'name button after template, taking off extension for neatness
    .Caption = Left(strTemp, Len(strTemp) - 4)
    .OnAction = "openTemplate"
    .Tag = strPath & strTemp
    End With
    End If
    strTemp = Dir
    Loop

    End Sub

    Sub openTemplate()
    'open template using caption of button clicked
    Word.Documents.Open CommandBars.ActionControl.Tag
    End Sub

    </font color=blue>
    It should pick up all the templates in your current workgroup templates file location, display them under a Button called CREAT in your Menu, and open them when you click on them...

    I have tested it quickly on my Word and its fine, though have done no error handling!! (oops)

    HTH or is of interest!!

    Cheers



    <img src=/S/coffeetime.gif border=0 alt=coffeetime width=32 height=48>
    Thanks,

    pmatz

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

    Re: New menu item (2003)

    Thanks for working out the details! It worked well in a quick test.

    Two minor comments:
    - I would copy the code into a standard module (in Normal.dot) instead of ThisDocument.
    - I would use Word.Documents.Add CommandBars.ActionControl.Tag in the openTemplate procedure, to create a new document based on the template, instead of opening the template itself.

  10. #10
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New menu item (2003)

    Points taken, I forgot you can put the Autoexec() anywhere, that makes more sense to put it in a module, and the Document.Add is much better than the .Open.

    Thanks Hans!
    Thanks,

    pmatz

  11. #11
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: New menu item (2003)

    I generally put code like this into an ordinary Sub or Function and then call that from AutoExec or an event procedure. It makes it much easier to maintain, and it can be called from multiple places when needed.

    StuartR

  12. #12
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New menu item (2003)

    I find myself now at a location where they have Word 97 instead of 2003. I was unable to implement Hans' suggestion and tried yours. It seems to partially work but I must have done something wrong. I went to altF11 clicked on Normal, modules then right clicked and selected insert. Then I pasted the code.

    The result is that I have a CREATE item on the menu bar and when I click on it I only have a small gray square with nothing in it. This computer is on a network and the file location is on a network drive.

    Any thoughts on what I did wrong?

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

    Re: New menu item (2003)

    Perhaps there are no workgroup templates? What happens if you change

    strPath = Word.Options.DefaultFilePath(wdWorkgroupTemplatesP ath) & ""

    to

    strPath = Word.Options.DefaultFilePath(wdUserTemplatesPath) & ""

  14. #14
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New menu item (2003)

    Thanks Hans. I regret to say that it was my error - I did not correctly identify the path to the workgroup templates. I continue to underestimate my ability to make mistakes and waste other people's time.

    thank you for the help.

  15. #15
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New menu item (2003)

    This is a really cool macro yet I have found a couple of limitations, I think.

    1. If I add folders to my workgroup templates location, they will show up as tabs on the FILE|NEW dialog box. When using this CREATE macro, there is no way to get to the other folders - it only shows what is in the "GENERAL" tab of fILE|NEW. Is there any way for the macro to recognize other folders within the workgroup folder?

    2. I have found that it only checks the folder contents when Word opens. How would I change it to be more dynamic - that is, check the folder contents each time I click on the CREATE menu item? For example, if I delete a template while word is open, it will continue to show with the CREATE macro until I close & reopen word.

    3. In my current workgroup folder, I have a template named "Original_Normal.DOT" which represents the default normal.dot before all my customizations. Oddly enough, this does not show up in the macro's list and I cannot find anything in the code that would prevent it. Below is the VBA code for the macro.

    Sub AutoExec()
    Dim cmdBr As CommandBar, cbC As CommandBarControl, c As CommandBarButton
    Dim strPath As String, strTemp As String

    Set cmdBr = Word.CommandBars("Menu Bar")

    'remove old CREATE Menubar
    For Each cbC In cmdBr.Controls
    If cbC.Caption = "CREATE" Then
    cbC.Delete
    End If
    Next cbC

    'Make CREATE menu
    Set cbC = cmdBr.Controls.Add(msoControlPopup)
    cbC.Caption = "CREATE"
    cbC.BeginGroup = True

    'Add template names to popup menu
    strPath = Word.Options.DefaultFilePath(wdWorkgroupTemplatesP ath) & ""
    strTemp = Dir(strPath)
    Do While strTemp <> ""
    'check for template extension
    If Right(strTemp, 4) = ".dot" Then
    Set c = cbC.Controls.Add(msoControlButton)
    With c
    'name button after template, taking off extension for neatness
    .Caption = Left(strTemp, Len(strTemp) - 4)
    .OnAction = "openTemplate"
    .Tag = strPath & strTemp
    End With
    End If
    strTemp = Dir
    Loop

    End Sub

    Sub openTemplate()
    'open template using caption of button clicked
    Word.Documents.Add CommandBars.ActionControl.Tag
    End Sub

Page 1 of 2 12 LastLast

Posting Permissions

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