For most cases, you are often using VBA code to do various tasks in Your Word. However, do you really get hang of the steps to run VBA code? Therefore, in this article, we offer a detailed description of those steps for you.
In the followings, we take Word 2010 as an example to show the detailed steps. And you can easily apply the method to other versions in a similar way.
Step 1 Open the “Developer”
- First of all, go to the “File”, and click “Options”.
- Next click “Customize Ribbon” to check whether the “Developer” is selected.
If checked, you can go to the Step 2; if not, you need do the followings:
(1). On the right sections of Word Options, you need choose “Main Tabs” under the “Customize Ribbon”.
(2). Now you will find the “Developer”, and then check it.
(3). Finally, click “OK” to close the window.
(4). Back to the home screen of your word, you can easily find the “Developer” tab.
Step 2 Check Securities for the Macro
Before running VBA code, you need follow this step to check whether the operating environment is secure to run your macro.
- After enabling the “Developer”, you need click “Macro Security” in the “Code” group.
- Then make sure the “Disable all macro with notifications” is checked in “Macro Setting”.
Step 3 Edit the VBA code
- Firstly, click “Visual Basic” in the “Code” group, on “Developer” tab or you can press “Alt” + “F11” in your keyboard to open the VBA editor.
- Then click “Insert”, in the drop-down menu, you can click “Module”.
- Next double click to open a new module.
- Finally, in the empty area of this project, you can edit your VBA code in it.
Step 4 Run VBA code
After editing the VBA code you need, next comes to run it.
- Chick “Run” (the green triangle like bellowed picture) in the toolbar or hit “F5” in your keyboard in the current module.
Alternative Option: Add Macro Buttons to the Quick Access Toolbar
When finishing above steps, you can also add shortcut button for your macro.
- Similarly, click “Options” in the “File” tab, and then click “Quick Access Toolbar”.
- Choose “Macros” and click “Add” to the toolbar after selecting “All Commands” from the “Choose commands from” drop down list.
- Then click “Ok” to close the window.
- Back to the document, you can find the macro is already in the Quick Access Toolbar. Therefore, you can easily click it to run your code.
Micky Ao is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including Excel fix and pdf repair software products. For more information visit www.datanumen.com