• Word Command for Add to Work Menu (English(U.S.)/Word 2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Word Command for Add to Work Menu (English(U.S.)/Word 2000)

    Author
    Topic
    #360691

    Hi Everyone:

    Does anyone know the VBA command for “Add to Work Menu”? I recorded a macro while adding a document to the work menu, but the macro only recorded my opening of a document & closing it. I couldn’t find anything under WordCommands that looked like it would do the job.

    Thanks in advance.

    Viewing 0 reply threads
    Author
    Replies
    • #543791

      Phil,

      Is this any help – its the “AddCurrentDocumentHere” macro from Word97

      Public Sub MAIN()
      Dim file$
      Dim N
      Dim numofmenus
      Dim count_
      Dim menuname$
      Dim Work
      Dim CurrentDocFileName$
      Dim x
      If WordBasic.Window() = 0 Or WordBasic.IsMacro() Then
          WordBasic.Beep
          WordBasic.PrintStatusBar _
               "The command is not available because a document window is not active."
          GoTo theend
      End If
      Dim dlg As Object: Set dlg = WordBasic.DialogRecord.DocumentStatistics(False)
      WordBasic.CurValues.DocumentStatistics dlg
      file$ = dlg.Filename
      If WordBasic.[Left$](file$, 8) = "Document" Then
          
          Set dlg = WordBasic.CurValues.FileSaveAs
          N = WordBasic.Dialog.FileSaveAs(dlg)
          If N = -1 Then WordBasic.FileSaveAs dlg
          If N = 0 Then GoTo theend
      End If
      numofmenus = WordBasic.CountMenus(0, 0)
      For count_ = 1 To numofmenus
          menuname$ = WordBasic.[MenuText$](0, count_, 0)
          If InStr(menuname$, "Wor&k")  0 Then Work = 1
      Next count_
      If Work = 0 Then WordBasic.ToolsCustomizeMenuBar Position:=-1, _
            MenuText:="Wor&k", Context:=0, Add:=1
      CurrentDocFileName$ = WordBasic.[FileName$]()
      x = InStr(CurrentDocFileName$, "")
      If x = 0 Then GoTo theend
      WordBasic.ToolsCustomizeMenus MenuType:=0, Category:=1, _
               Name:="FileOpenFile", Menu:="Wor&k", _
               MenuText:=WordBasic.[FileNameInfo$](WordBasic.[FileName$](0), 3), _
               Add:=1, CommandValue:=CurrentDocFileName$, Context:=0
      theend:
      End Sub
      
      

      If you have problems with this it will be because I have inserted VBA line breaks as suggested by the Lounge.

      Actually I would find the matching macro for Excel most useful if anyone can build it from the above code – it’s beyond my capabilities.

      HTH

    Viewing 0 reply threads
    Reply To: Word Command for Add to Work Menu (English(U.S.)/Word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: