logo
search
Office for Mac Issues

How to Use a Word VBA Macro to Save a Text File as DOCX on Mac

Ayan MasoodAyan Masood Oct 22, 2026 869 views

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.

How to Use a Word VBA Macro to Save a Text File as DOCX on Mac
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Go to the Developer tab in the Word for Mac ribbon and click on the 'Visual Basic' button to open the VBA editor interface.

2
Insert a new module

In the Project Explorer pane on the left, right-click your active document's name, select 'Insert', and then click 'Module'.

3
Paste the VBA code

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

4
Assign a keyboard shortcut

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.

Implement the SaveAsDocx VBA Macro in Word for Mac
Mac Compatibility Confirmed: The provided SaveAs2 method functions correctly in recent versions of Word for Mac, allowing seamless format conversion without modifying the source text file.
Free Microsoft Office alternative

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. 1. Download WPS Office: Visit the official WPS Office website and download the Mac installer package.
  2. 2. Install the application: Run the downloaded DMG file and follow the on-screen instructions to install WPS Office on your Mac.
  3. 3. Open your documents: Launch WPS Writer and open your existing text or DOCX files with full formatting and feature preservation.
100% compatible with Microsoft Office formats including DOCX, XLSX, and PPTXLightweight application that runs smoothly on Mac devices without heavy resource usageFree to use with a familiar, easy-to-navigate interface that requires no learning curve
microsoft office alternative - wps office

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.