Monday, December 18, 2017

Step 1 - Start with the macro recorder

Step 1 - Start with the macro recorder

The easiest way to start programming with VBA in Office for Mac 2011 is to use the Macro Recorder. The recorder simply records a task that you perform in your Office app, and then converts it into VBA code. Later, you can look at the code that was generated to learn what VBA code is used to complete that action.

You may be wondering, why do I need to learn the code, if the recorder can do the work for me? As you use the Macro Recorder to create macros, you may find that there are limits to what you're able to record, and you'll need to go into the code to create more complex capabilities in your macro.

Let's look at an example of how to record the task of deleting a row from a table in Word.

  1. First create a table in Word.

    Create Table

  2. Place your cursor in the first cell of the table. In the example above, we'll place the cursor on the cell Andrew.

  3. Click Tools > Macro > Record New Macro

  4. Change the macro name to DeleteRow, and click OK.

Tip:  The macro name can't contain spaces or special characters.

  Record Macro

  1. Now with the recorder started, select the Table Layouttab, and click Delete > Delete Rows.

    Delete Row

  2. Stop the Macro Recorder by clicking Tools > Macro > Stop Recording.

    Now that you've recorded your action, let's take a look at the code

    Note:  The Macro Recorder does not record keystroke.

 Step 1 - Start with the Macro Recorder

Step 2 - Read and Understand the Code

Step 3 - Learn Programming Fundamentals

Step 4 - Share Your Macro with Others

Step 5 - Real World Examples

No comments:

Post a Comment