How to Use a Word VBA Macro to Save a Text File as DOCX on Mac
Question details
The user is looking for a VBA macro to automatically save an active text file as a DOCX document in Word for Mac, and assign it to a keyboard shortcut.

- Product
- Microsoft Word
- Device & OS
- Mac
- Scenario
- Automating repetitive file format conversions from text formats to standard DOCX formats using macros.
- Observed behavior
- The user needs to verify if the Windows-oriented SaveAs2 VBA method functions correctly within the Mac environment to complete the conversion.
Ensure that the Developer tab is enabled in your Word for Mac ribbon and always test new macros on a copy of your document to prevent accidental data loss.
Implement the SaveAsDocx VBA Macro in Word for Mac
Use this VBA script to automatically extract the current file name, change the extension, and save it in the standard XML document format (DOCX).
This macro utilizes the SaveAs2 method to convert the active document's format. While there are sometimes minor differences in VBA execution between Mac and Windows, this specific snippet has been tested and confirmed to work on Word for Mac.
Go to the Developer tab in the Word for Mac ribbon and click on the 'Visual Basic' button to open the VBA editor interface.
In the Project Explorer pane on the left, right-click your active document's name, select 'Insert', and then click 'Module'.
Copy and paste the following code into the blank module window: Sub SaveAsDocx() Dim FN As String: FN = ActiveDocument.FullName: FN = Left(FN, InStrRev(FN, ".")) & "docx": ActiveDocument.SaveAs2 FileName:=FN, FileFormat:=wdFormatXMLDocument: End Sub
Return to the main Word window, go to Tools > Customize Keyboard. Under Categories, select 'Macros', find 'SaveAsDocx' in the list on the right, and assign your preferred shortcut key combination.

Experience Seamless Document Management with WPS Office
If you're experiencing macro compatibility issues in Microsoft Office for Mac, consider switching to WPS Office. It provides a free, lightweight, and highly compatible alternative with a familiar user interface that makes transitioning effortless.
- 1. Download WPS Office: Visit the official WPS Office website and download the Mac installer package.
- 2. Install the application: Run the downloaded DMG file and follow the on-screen instructions to install WPS Office on your Mac.
- 3. Open your documents: Launch WPS Writer and open your existing text or DOCX files with full formatting and feature preservation.

Frequently Asked Questions
Why do some VBA macros work on Windows but not on Mac?
Word for Mac uses a different underlying operating system and file path structure (often utilizing POSIX paths or sandboxing restrictions), which can cause certain Windows-specific VBA commands to fail or require structural adjustments to function properly.
How do I enable the Developer tab in Word for Mac?
Go to Word > Preferences > Ribbon & Toolbar. In the right pane under 'Customize the Ribbon', scroll down to find 'Developer', check the box next to it, and click Save to display it on your main ribbon.
Can I save files as other formats using this VBA macro?
Yes, you can adapt the macro for different output formats by changing the FileFormat property (e.g., changing wdFormatXMLDocument to wdFormatPDF) and modifying the file extension string (".docx" to ".pdf") in the provided VBA code.




