Write macro in Word 2011 for Mac

Instead of recording macro in Word 2011, you can write your own macro in Word 2011 for Mac with VBA. Let us see this with an example by writing a macro for displaying the current date and time in a Message Box.

Step 1: Click Tools menu then Macro followed by Visual Basic Editor.

Visual Basic Editor in Word 2011

Step 2: In the Project navigation, select the currently opened document. When add the macro under Modules in Normal Project the macro will be available through out the application. But by selecting “ThisDocument”, this newly created macro will only be available for the current document.

Project Navigator in Word 2011

Step 3: If you cannot see the Visual Basic Editor window then click View Code option under Project navigator section.

View Code in Project Navigator

Step 4: Click Insert menu and select Procedure from the menu list.

Insert VBA Procedure

Step 5: In the Add Procedure window, enter a name for the procedure, select type as Sub and Scope as Public.

Add Procedure in VBA Editor

Step 6: Type the following in the newly created procedure. This would display today’s date in a message box.

Public Sub DisplayDate()

MsgBox Date$, vbOKOnly, “Today’s date”

End Sub

Step 6: Now to run or test this procedure, click Run menu and select Run Sub/UserForm from the menu list.
Run the Procedure in VBA
This should display the following Macros window, select macro with name as DisplayDate and click Run button.
Macros window in Word 2011
Now you should see the following Message Box with the current date.
Message box to display current date
The newly created macro will be available as part of the Macros. And if you want this macro to be available permanently with this document then make sure to save the document as “Word Macro-Enabled Document.docm
Macros window with newly created Macro.

In Category: Apple, Mac, MS Office

Ravi Shankar

A Software developer and blogger who is always looking to provide technical help to the wider community.

Show 0 Comments
No comments yet. Be the first.

Leave a Comment

Get your free copies of the following tech guides by joining the Digital Answers mailing list.