------------------------------------------------
If you are provided with a solution that involves Visual Basic code (VBA or macros) and are unfamiliar with the process to integrate it into Word for use, this short step by step will show you how. First locate the version of Word you are working with, and then apply the steps as illustrated.
In the lounge, VBA code or macros are presented to you in Code Tags. These tags will ensure the code is compatible with the VBA Editor into which you will paste the code. It also conveniently provides a Select All option to easily copy the entire block of code without having to drag to select it. Try it with this example:
Code: Select all
Sub SampleMacro()
Selection.Font.Color = wdColorRed
Selection.Font.Size = 48
Selection.Font.Name = "Bauhaus 93"
Selection.TypeText Text:="Hello, Word!"
End Sub
------------------------------
Word 2007 / 2010 / 2013
Please note: Screenshots below are taken from Word 2013. Older versions might have small variances.
1. Use the Select All option to select the VBA code from the post
2. Copy the selected code
3. Open Word and the document where the code must be placed
4. Press ALT+F11 (to open the VBA Editor) - as seen in screenshot below 5. Select Insert, Module (unless the post specifies otherwise)
6. Paste the code into the module on the right
7. Click the Save button
8. Close the VBA Editor
To Use/Run the macro in Word
1. Access the VIEW tab of the ribbon
2. Click on the Macros button (and select View Macros) - as seen in screenshot below 3. Select your macro and click on Run - as seen in screenshot below --- You can add an optional description for the macro (useful if you have several macros in the same document)
4. If you want to assign shortcut keys to the macro so you can trigger it from the keyboard, follow the points in the screenshot below --- Access the File ribbon and choose Options (in Word 2007: use the Office Orb and click Word Options)
--- Select 'Customize the Ribbon' (in Word 2007: Customize) and click the button "Customize..." next to Keyboard shortcuts.
--- If you want the macro to be available in all documents, make sure that Normal.dot is selected in the 'Save changes in' box
--- Select Macros in the list of Categories on the left hand side
--- Select your macro in the list of Macros on the right hand side
--- Click in the 'Press new shortcut key' box
--- Press the desired keyboard shortcut
--- Click Assign
Word 2003
1. Use the Select All option to select the VBA code from the post
2. Copy the selected code
3. Open Word and the document where the code must be placed
4. Press ALT+F11 (to open the VBA Editor) - as seen in screenshot below 5. Select Insert, Module (unless the post specifies otherwise)
6. Paste the code into the module on the right
7. Click the Save button
8. Close the VBA Editor
To Use/Run the macro in Word
1. Access the Tools menu
2. Click on the Macro, and then Macros command - as seen in screenshot below (or press ALT+F8) 3. Select your macro and click on Run - as seen in screenshot below --- You can add an optional description for the macro (useful if you have several macros in the same document)
4. If you want to assign shortcut keys to the macro so you can trigger it from the keyboard, follow the points below
--- In Word, Tools | Customize...
--- Click Keyboard...
--- If you want the macro to be available in all documents, make sure that Normal.dot is selected in the 'Save changes in' box
--- Select Macros in the list of Categories on the left hand side
--- Select your macro in the list of Macros on the right hand side
--- Click in the 'Press new shortcut key' box
--- Press the desired keyboard shortcut
--- Click Assign
--- Click Close