How to Run VBA Code in Your Word

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”

  1. First of all, go to the “File”, and click “Options”.Click "Options"
  2. 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.Enable "Developer"

(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.

  1. After enabling the “Developer”, you need click “Macro Security” in the “Code” group.Click "Macro Security"
  2. Then make sure the “Disable all macro with notifications” is checked in “Macro Setting”.Security Setting

 

Step 3 Edit the VBA code

  1. 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.
  2. Then click “Insert”, in the drop-down menu, you can click “Module”.
  3. Next double click to open a new module.Add New Module
  4. Finally, in the empty area of this project, you can edit your VBA code in it.Edit Code

 

Step 4 Run VBA code

After editing the VBA code you need, next comes to run it.

  1. Chick “Run” (the green triangle like bellowed picture) in the toolbar or hit “F5” in your keyboard in the current module.Run VBA Code

 

Alternative Option: Add Macro Buttons to the Quick Access Toolbar

When finishing above steps, you can also add shortcut button for your macro.

  1. Similarly, click “Options” in the “File” tab, and then click “Quick Access Toolbar”.
  2. Choose “Macros” and click “Add” to the toolbar after selecting “All Commands” from the “Choose commands from” drop down list.
  3. Then click “Ok” to close the window.
  4. 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.Add Marcos to Quick Access Toolbar

Author Introduction:

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

Leave a Reply

Your email address will not be published. Required fields are marked *