Document Editing Problems

Use a Word Table Field as the Default Save As File Name

Adam DavisAdam Davis Nov 25, 2026 869 views

Question details

Suggest a file name based on a person's name entered in a Word table cell.

Use a Word Table Field as the Default Save As File Name
Product
Microsoft Word
Device & OS
not provided
Scenario
A user fills in a name in a table and wants to use it when saving the document.
Observed behavior
The Save As dialog should suggest a file name derived from the table cell.
Before you start

Identify the table number and the row and column containing the name. Check whether recipients can run trusted macros, since Word security settings may block them.

Solution 1Recommended

Use a Word macro to suggest a file name from a table cell

Run a macro that reads the name, cleans it for use as a file name, and opens the Save As dialog.

This macro uses the first table and cell in row 2, column 2. Change those numbers to match your document. It suggests a name when you run the macro; it does not change Word's normal Save As behavior.

1
Open the VBA editor

In Word, open the document and select Developer > Visual Basic. If the Developer tab is hidden, enable it in Word's ribbon settings.

2
Add the macro

In the VBA editor, select the document or its template in the project pane, choose Insert > Module, and paste this code: Sub SaveUsingTableName() Dim personName As String Dim badChar As Variant Dim i As Integer Dim saveDialog As Dialog On Error GoTo TableError personName = ActiveDocument.Tables(1).Cell(2, 2).Range.Text On Error GoTo 0 For i = 0 To 31 personName = Replace(personName, Chr(i), " ") Next i For Each badChar In Array("\", "/", ":", "*", "?", Chr(34), "<", ">", "|") personName = Replace(personName, badChar, "-") Next badChar personName = Trim(personName) Do While Len(personName) > 0 If Right(personName, 1) <> "." And Right(personName, 1) <> " " Then Exit Do personName = Left(personName, Len(personName) - 1) Loop If Len(personName) = 0 Then MsgBox "Enter a name in the table cell first." Exit Sub End If Set saveDialog = Dialogs(wdDialogFileSaveAs) saveDialog.Name = "Person - " & Left(personName, 80) saveDialog.Show Exit Sub TableError: MsgBox "Check the table, row, and column numbers in the macro." End Sub

3
Save the macro

Select File > Save As and save the document as a Word Macro-Enabled Document (.docm), or store the macro in a macro-enabled template. A standard .docx file cannot retain VBA macros.

4
Run the macro to save

Enter the person's name in the configured cell, then select View > Macros, choose SaveUsingTableName, and select Run. Review the suggested name, location, and file type in the Save As dialog before selecting Save.

Use a Word macro to suggest a file name from a table cell
Macro security: Recipients may see a security warning or be unable to run the macro. Enable macros only when the document and its source are trusted. If macros cannot be used, consider an external automation process or enter the file name manually.
Free Microsoft Office alternative

Edit Word Documents in WPS Writer

WPS Writer is a free, lightweight alternative with a familiar interface for editing Word documents. Open compatible files and continue working in a similar layout as you move between office suites; the Word VBA solution above is not a fix provided by WPS.

Edit names and other information in document tablesOpen and save compatible Microsoft Word DOC and DOCX filesUse a familiar interface for everyday document editingWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Will Word automatically use a table cell as the file name?

Not normally. Run the macro through View > Macros to suggest a name from the configured cell in the Save As dialog.

How do I select a different cell for the file name?

In the VBA editor, change Tables(1).Cell(2, 2) to the appropriate table number, row, and column. For example, Cell(3, 1) reads row 3, column 1.

Why does the macro not run for another user?

Their Word macro security settings may block or disable it. Distribute macro-enabled files carefully, and ask users to enable macros only if they trust the document and its source.

Can I keep the macro in a DOCX file?

No. Save it in a macro-enabled .docm document or a macro-enabled template. Check the file type in the Save As dialog before saving a copy.