content of Work menu lost 
Author Message
 content of Work menu lost

When deleting the Data key in Registry so as to fix some corruption in
Word's menus or toolbars, the contents of the Work menu is removed.  Is
there any way to back up the Work menu?

Larry



Wed, 23 Nov 2005 04:40:42 GMT  
 content of Work menu lost
Hi Larry,

Quote:
> When deleting the Data key in Registry so as to fix some corruption in
> Word's menus or toolbars, the contents of the Work menu is removed.  Is
> there any way to back up the Work menu?

No built-in way, but here's a macro that should help. At least, it works
here. What it does is open each document in the Work menu list, save the
full path into a string, which is then saved in the Registry. The
documents are closed without saving changes.

You could run into some problems if prompts are displayed when the
documents are opened. Please note, also, that the code is based on macro
commands available in Word 2002. Since you didn't specify which version
of Word you have, I just did it optimally for the version I have
installed.

Sub BackupWorkMenu()
    Dim cb As Office.CommandBar, ctl As Office.CommandBarButton
    Dim lPos As Long, szWorkMenuContent As String
    Dim doc As Word.Document, szRegPath As String
    Dim szVersion As String

    Set cb = CommandBars("Menu bar").Controls("Work").CommandBar
    lPos = 0
    szVersion = Application.Version
    szRegPath = "HKey_Current_User\Software\Microsoft\Office\" _
      & szVersion & "\Word\WorkMenu"
    Application.AutomationSecurity = msoAutomationSecurityForceDisable
    WordBasic.DisableAutoMacros
    Application.DisplayAlerts = wdAlertsNone

    For Each ctl In cb.Controls
        'Skip the first entry: "Add to Work Menu"
        If lPos <> 0 Then
            ctl.Execute
            Set doc = ActiveDocument
            szWorkMenuContent = szWorkMenuContent & doc.FullName & ";"
            doc.Saved = True
            doc.Close wdDoNotSaveChanges
        Else
            lPos = 1
        End If
    Next ctl
    szWorkMenuContent = Left(szWorkMenuContent, _
      Len(szWorkMenuContent) - 1)
    System.PrivateProfileString("", szRegPath, "DocList") _
      = szWorkMenuContent
    Application.AutomationSecurity = msoAutomationSecurityByUI
End Sub

Sub ResetoreWorkMenu()
    Dim cb As Office.CommandBar, ctl As Office.CommandBarButton
    Dim lPos As Long, szWorkMenuContent As String
    Dim doc As Word.Document, szRegPath As String
    Dim szVersion As String, i As Integer
    Dim arrWorkMenuContent() As String

    Set cb = CommandBars("Menu bar").Controls("Work").CommandBar
    lPos = 0
    szVersion = Application.Version
    szRegPath = "HKey_Current_User\Software\Microsoft\Office\" _
      & szVersion & "\Word\WorkMenu"
    Application.AutomationSecurity = msoAutomationSecurityForceDisable
    WordBasic.DisableAutoMacros
    Application.DisplayAlerts = wdAlertsNone

    szWorkMenuContent = System.PrivateProfileString("", _
     szRegPath, "DocList")
    arrWorkMenuContent() = Split(szWorkMenuContent, ";")

    For i = 0 To UBound(arrWorkMenuContent)
        Set doc = Documents.Open(arrWorkMenuContent(i), False, True, _
         False, , , , , , , , True, False, , True)
        cb.Controls(1).Execute
        doc.Saved = True
        doc.Close wdDoNotSaveChanges
    Next i
    Application.AutomationSecurity = msoAutomationSecurityByUI
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



Fri, 25 Nov 2005 22:45:43 GMT  
 content of Work menu lost
Cindy,

That's an incredible-looking macro, Cindy.  Sorry I didn't pick up your
reply earlier.  However, I have Word 97 and it doesn't include this:

Application.AutomationSecurity = msoAutomationSecurityForceDisable

So, is there any possibility the macro could be altered to work without
the AutomationSecurity property?

What I'd really like, though, would be a custom version of the Work menu
that would work like this.  You create a special menu just for macros
that open documents using Documents.Open.  When document A is active,
you run macro X that creates macro A into which the path of Document A
is inserted.  Macro X then adds a button for macro A to the special
menu.  Morever, this menu has an automatically underlined sequential
number for each button.

With such a customized work menu way you could have as many documents on
the menu, move them around, and so on.  It would be a "super" Work menu.

The main difficulty I see is that I don't think it's possible for VBA to
carry on automated steps within the VB editor interface itself, which
would be necessary for creating macro A automatically.

If that's not possible, what about this approach, which might be
simpler:  a macro that creates a shortcut to the ActiveDocument and
moves it to a certain folder where a bunch of similar shortcuts are
kept?  I have no idea how this might be done, but in theory it seems
more doable to me than my first suggestion.

Larry



Thu, 01 Dec 2005 15:36:21 GMT  
 content of Work menu lost
Hi Larry,

Quote:
> However, I have Word 97 and it doesn't include this:

> Application.AutomationSecurity = msoAutomationSecurityForceDisable

> So, is there any possibility the macro could be altered to work without
> the AutomationSecurity property?

Certainly. But then you have to be sure you are sitting right in front of
the screen so that you can tell Word to disable macros (you don't want
AutoOpen stuff to be running).

Quote:
> The main difficulty I see is that I don't think it's possible for VBA to
> carry on automated steps within the VB editor interface itself, which
> would be necessary for creating macro A automatically.

Actually, it can. It requires the VBExtensibility Object library (VBE). If
you're curious, set a reference to this in the VBEditor/Tools/References.
Go to a VBA module, type VBComponent, then press F1 to open the help
files.

But I don't have the time or patience, at the moment, to work this out for
you.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



Thu, 01 Dec 2005 17:45:20 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Contents of Work menu disappeared

2. I've lost my FILE menu from the menu bar

3. Lost Toolbars- Lost all menus!!!!!!!!!!!!!!!!!!!!!!!!!

4. Right Click Drop down menu not working and Action menu empty

5. Empty action menu, popup menu doesn't work anymore

6. Dropdown menus and right click menus don't work with Mouse

7. Work menu and MRU menu not keeping documents

8. Work menu and MRU menu not keeping documents

9. Empty action menu, popup menu doesn't work anymore

10. Work Menu, Not Really Working


 
Powered by phpBB® Forum Software © phpBB Group