WD: Macro to Dock Toolbars That Are Beyond Screen Borders

ID: Q173631

The information in this article applies to:

SUMMARY

This article contains a WordBasic macro to dock (move) any active toolbars that are not visible on screen to the top of the active Microsoft Word window.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/supportnet/refguide/ 

This WordBasic macro lists the names of all toolbars in Word, and then prompts the user to enter the name of the missing toolbar.

   Sub MAIN
      ' Create new document for inserting toolbar names.
      FileNewDefault
      ' Loop through all toolbars in Normal template.
      For i = 1 To CountToolbars(0)
         ' Insert toolbar names into documents.
         Insert ToolbarName$(i) + Chr$(13)
      Next i
      ' Build variable for prompt.
      msg$= "Type the missing Toolbar name from the list at "
      msg$= msg$ + "the left of this Dialog box then click OK."
      ' If Cancel is selected or incorrect info is entered that
      ' would cause an error, trap the error and resume to next line.
      On Error Resume Next
      ' Display InputBox to get name of toolbar to dock.
      Lostbar$ = InputBox$(msg$)
      ' Dock the toolbar.
      MoveToolbar Lostbar$, 1, 10, 100
      ' Close the document created earlier.
      FileClose 2
   End Sub

To dock a single toolbar, type the following WordBasic command in a blank macro window and then run the macro

       MoveToolBar  "<toolbar name>",1,10,100

where <toolbar name> is the name of the toolbar displayed in the View Toolbars dialog box.

Additional query words:

Keywords          : kbui wordnt kbmacroexample winword word6 word7 word95 word 
Version           : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a
Platform          : WINDOWS
Issue type        : kbhowto

Last Reviewed: April 9, 1999