Home

MacOffice

This site will look better if you upgrade to a browser that supports web standards.

Storing and retrieving Work menu items in a text file

Word stores your Work menu items in the ~/Library/Preferences/Microsoft/com.microsoft.Word.prefs.plist file, where ~ is your home folder. If this file ever gets corrupted or you have to run Remove Office, you'll lose your Work menu items. One way to preserve them is to store the items in a safe place. I choose to use an add-in to store the items in a text file store in the ~/Library/Application Support/Microsoft Office/Word folder. This folder isn't created by Word or Office (it should be, but that's a different story), so the add-in creates the folder if it doesn't already exist.

Note that, once you create your text file, you can edit the file directly using any text editor, to add or delete Work menu items.

Store Work menu items in a text file

This macro stores the Work menu items in a text file and deletes them from the menu:

    Public Sub UnloadWorkMenuToTextFile()
        Dim nFileNum As Long
        Dim i As Long
        Dim sPathSep As String
        Dim sTextFilePath As String
        Dim sTextFileFullName As String
        sPathSep = Application.PathSeparator
        sTextFilePath = PrepSupportFolder
        If Len(sTextFilePath) > 0 Then
            sTextFileFullName = sTextFilePath & sPathSep & "jemWdWorkMenu.txt"
            nFileNum = FreeFile
            If Dir(sTextFileFullName) <> "" Then Kill sTextFileFullName
            Open sTextFileFullName For Output As #nFileNum
            For i = WorkMenuItems.Count To 1 Step -1
                With WorkMenuItems(i)
                    Write #nFileNum, .Path & sPathSep & .Name
                    .Delete
                End With
            Next i
            Close #nFileNum
        End If
    End Sub

This macro checks to see if the storage folder exists. As written it's designed only for MacWord v.X or 2004, but it could be modified for earlier versions of MacWord or WinWord:

    Public Function PrepSupportFolder() As String
        Dim sPathSep As String
        Dim sPrepSupportPath As String
        sPathSep = Application.PathSeparator
        #If Mac Then
            If Application.Version >= 10 Then
                sPrepSupportPath = Options.DefaultFilePath(wdUserOptionsPath)
                If Len(Dir(sPrepSupportPath, vbDirectory)) = 0 Then _
                    sPrepSupportPath = UCase(Left(sPrepSupportPath, 1)) & _
                    Mid(sPrepSupportPath, 2)
                sPrepSupportPath = Left(sPrepSupportPath, _
                    InStr(sPrepSupportPath, "preferences") - 1) & "Application Support"
                If Len(Dir(sPrepSupportPath, vbDirectory)) = 0 Then _
                    MkDir sPrepSupportPath
                sPrepSupportPath = sPrepSupportPath & sPathSep & "Microsoft Office"
                If Len(Dir(sPrepSupportPath, vbDirectory)) = 0 Then _
                    MkDir sPrepSupportPath
                sPrepSupportPath = sPrepSupportPath & sPathSep & "Word"
                If Len(Dir(sPrepSupportPath, vbDirectory)) = 0 Then _
                    MkDir sPrepSupportPath
            End If
        #End If
        If Len(Dir(sPrepSupportPath, vbDirectory)) > 0 Then _
            PrepSupportFolder = sPrepSupportPath
    End Function

Restore Work menu items from a text file

Of course, you'll want to retrieve the items when the add-in is loaded:

    Public Sub LoadWorkMenuFromTextFile()
        Dim nFileNum As Long
        Dim sInput As String
        Dim sTextFilePath As String
        Dim sTextFileFullName As String
        sTextFilePath = GetSupportFolder
        If Len(sTextFilePath) > 0 Then
            sTextFileFullName = sTextFilePath & _
                Application.PathSeparator & "jemWdWorkMenu.txt"
            nFileNum = FreeFile
            If Len(Dir(sTextFileFullName)) > 0 Then
                Open sTextFileFullName For Input As #nFileNum
                Do While Not EOF(nFileNum)
                    Input #nFileNum, sInput
                    If Dir(sInput) <> "" Then WorkMenuItems.Add sInput
                Loop
                Close #nFileNum
            End If
        End If
    End Sub
    Public Function GetSupportFolder() As String
        Dim sPathSep As String
        Dim sSupportPath As String
        sPathSep = Application.PathSeparator
        #If Mac Then
            If Application.Version >= 10 Then
                sSupportPath = Options.DefaultFilePath(wdUserOptionsPath)
                If Len(Dir(sSupportPath, vbDirectory)) = 0 Then _
                    sSupportPath = UCase(Left(sSupportPath, 1)) & _
                    Mid(sSupportPath, 2)
                sSupportPath = Left(sSupportPath, _
                    InStr(sSupportPath, "preferences") - 1) & "Application Support" _
                    & sPathSep & "Microsoft Office" & sPathSep & "Word"
            End If
        #End If
        If Len(Dir(sSupportPath, vbDirectory)) > 0 Then _
            GetSupportFolder = sSupportPath
    End Function

Automating storing and restoring Work menu items

To automate the above macros in an add-in, the following macros are called when the add-in is loaded and unloaded:

    Public Sub AutoExec()
        LoadWorkMenuFromTextFile
    End Sub

    Public Sub AutoClose()
        UnloadWorkMenuToTextFile
    End Sub

Click to download an add-in that implements this technique, as well as adds an item to the Work menu that makes deleting items easier.

Valid XHTML 1.1 Valid CSS Made on a Macintosh

Quick Links

Remove items from the Work menu

Automatically add an add-in or file to the Work menu

Download the jemWordWorkMenu add-in

About add-ins