Friday, April 29, 2011

WordWrap toolbar button for Excel 2003

Adding Custom Macros to an Excel Toolbar

Before adding these custom buttons, you should create your own personal add-in. Don't worry, this is a piece of cake.
  1. Open up a new workbook.
  2. Start up VBA. (Press Alt+F11)
  3. Insert a new module. (Insert > Module)
  4. Copy and paste the VBA code into the module.
  5. (Take note of what the macro is called).
  6. Get out of VBA. (Press Alt+Q)
  7. Save your workbook as an addin (.xla) file, calling it something like My_Addin.xla
  8. Exit out of Excel, then start it up again.
  9. Enable your new addin (Go to Tools > Add-Ins and select your new addin).
Creating a new macro button in a toolbar.
  1. Go to Tools > Customize
  2. In the Commands tab, click on the Macros category.
  3. Copy (drag and drop) the Custom Button to one of your toolbars.
  4. Right-click on the button and select Default Style to display only the image.
  5. Copy and paste the button image as described above.
  6. Right-click on the button and select Assign Macro ...
  7. Type the exact name of the macro and select OK

Word Wrap Toolbar Button


ImageCommand Description
word wrap toolbar button Toggle word wrap within a selected cell or range of cells.

Sub WordWrapBtn() 
' Word Wrap Button Macro 
    Dim btnstate As Boolean 
    btnstate = Selection.WrapText 
    With Selection 
        If btnstate Then 
        .WrapText = False 
        Else 
        .WrapText = True 
        End If 
    End With 
End Sub