Saving a Document with Macros
Macros
are created using Visual Basic for Applications (VBA) code. If you add a
macro to a document, you need to save it with a file name extension
that ends with an “m”, either Word Macro-Enabled Document (.docm), or
Word Macro-Enabled Template (.dotm). If you try to save a document
containing a macro with a file name extension that ends with an “x”
(such as .docx or .dotx), Word displays an alert message, restricting
the operation. These Word file types are designated to be VBA code-free.
Save a Document with Macros
- Click the File tab, and then click Save As.
- Click the Save in list arrow, and then click the drive or folder where you want to save the file.
- Type a document file name.
- If necessary, click the Save as type list arrow, and then select the macro format you want:
- Word Macro-Enabled Document. A document (.docm) that contains VBA code.
- Word Macro-Enabled Template. A template (.dotm) that includes preapproved macros.
- Click Save.
Opening a Document with Macros
When
you open a document with a macro, VBA, or other software code, Word
displays a security warning to let you know the document might contain
potentially harmful code that may harm your computer. If you know and
trust the author of the document, you can change security options to
enable the macro content and use the document normally. If you don’t
trust the content, you can continue to block and disable the content and
use the document with limited functionality in Protected view (New!). If you don’t want a security alert to appear, you can change security settings in the Trust Center in Word Options.
Open a Document with Macros
- Click the File tab, and then click Open.
- If necessary, click the File as type list arrow, and then the document type that contains a macro.
- If the file is located in another folder, click the Look in list arrow, and then navigate to the file.
- Click the document with macros you want to open, and then click Open.
- Click the File tab, click Info, click the Enable Content button (New!), and then click Advanced Options. To enable all content (make trusted), click Enable All Content on the menu.
- You can also click Enable Content in the Message Bar with the Security Warning.
- If you trust the document content, click the Enable content for this session option to use it. If you don’t trust it, click the Help protect me from unknown content (recommended) option to block and disable the macros.
- Click OK.