How to Remove Leading Zeros from Alphanumeric Mail Merge Values in Word
Question details
The user needs to strip leading zeros from alphanumeric data strings during a mail merge process while preserving the letters and the remaining numbers.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Executing a mail merge where the source data contains alphanumeric identifiers (e.g., 00123FR56789332) that must be displayed without their leading zeros (e.g., 123FR56789332) in the final output document.
- Observed behavior
- The merged document displays the raw alphanumeric string complete with unwanted leading zeros, instead of formatting it to remove them.
Check your original data source spreadsheet to see if you can reformat or clean the alphanumeric column directly before initiating the mail merge.
Remove Leading Zeros in the Source Data (Recommended)
The best and most reliable method is to clean the alphanumeric strings in your Excel or Spreadsheet data source before connecting it to Word.
Data manipulation is generally best performed in the data source itself. Word's built-in Mail Merge feature does not provide a direct formatting switch to manipulate alphanumeric text strings, as numeric switches only work on pure numbers.
Open your original data file (Excel or CSV) containing the alphanumeric values.
Insert a new column next to your target data. Use a text manipulation formula to strip the leading zeros. Alternatively, you can use the Find and Replace tool if your data follows a strict pattern.
Save the spreadsheet with the cleaned data column. Open your Word document, go to the Mailings tab, select 'Select Recipients', and reconnect your updated spreadsheet, using the new helper column as your merge field.

Run a VBA Macro After Merging
Use this solution if you cannot alter the source data. A VBA macro can search the finalized merge document and strip leading zeros matching your alphanumeric pattern.
Easily Manage Mail Merge Data with WPS Office
WPS Office provides an all-in-one suite with powerful spreadsheet and word processing tools. You can easily clean your alphanumeric source data in WPS Spreadsheet and execute a flawless mail merge in WPS Writer without complex macros.
- 1. Prepare data in WPS Spreadsheet: Open your data file in WPS Spreadsheet and use formulas or Find/Replace to strip leading zeros from your alphanumeric column.
- 2. Save the clean source file: Save your updated data as a standard .xlsx or .csv file.
- 3. Start WPS Writer Mail Merge: Open your template in WPS Writer, navigate to the References tab, and click Mail Merge to connect your cleaned spreadsheet.
- 4. Insert fields and merge: Insert the cleaned data fields into your document and click 'Merge to New Document' to generate your files with perfect formatting.

Frequently Asked Questions
Why does Word keep leading zeros in my mail merge?
Mail merge pulls the raw, underlying data from your source file rather than the display formatting. If the source file stores the leading zeros as part of a text string or raw value, Word will import and display them exactly as they are stored.
Can I use a numeric picture switch (\#) to remove leading zeros from alphanumeric data?
No. Numeric picture switches in Word (such as \# "0") only work on purely numeric data. If your merge field contains letters (alphanumeric), Word treats it as text, and the numeric formatting switch will be ignored.
Will the VBA macro work if my merge fields are in document headers?
The standard VBA macro provided only targets the main body of the document. To process alphanumeric values located in headers, footers, or text boxes, the macro must be specifically adapted to loop through all 'StoryRanges' within the Word document.




