How to Generate Unique Survey Codes for PDF Mailings
Question details
The user needs a method to generate 1,500 unique survey codes and place a different code on the first page of each printed or distributed PDF survey.

- Product
- PDF / Word Processor
- Device & OS
- not provided
- Scenario
- Preparing a batch of printed or digital PDF surveys where each recipient requires a unique access code to take the survey online.
- Observed behavior
- The goal is to automatically generate and insert a unique code onto the welcome letter of each survey document before exporting it as a final PDF.
Ensure you have a spreadsheet application to generate your list of unique codes and a word processor that supports mail merge functionalities for PDF creation.
Use Mail Merge to Create Unique Survey PDFs
Combine a spreadsheet of unique codes with your word processor's mail merge feature to dynamically generate individual PDFs for each survey.
A barcode form field cannot automatically generate sequential or random unique text codes across multiple printed copies. The most efficient way to achieve this without complex programming is by using a standard mail merge.
Open a spreadsheet program. Create a column named 'Survey Code' and generate 1,500 unique codes using random formulas, sequential numbers, or a database export. Save this spreadsheet file.
Open your word processor and create your standard 10-page survey document. On the first page, type your welcome message, leaving an empty space where the unique code should appear.
Navigate to the Mailings or References tab. Select your saved spreadsheet as the data source, then click 'Insert Merge Field' and choose the 'Survey Code' column to place it in the designated space.
Complete the mail merge by selecting 'Merge to New Document' or 'Merge to Printer'. If merging to a printer, select 'Print to PDF' to generate the final PDF files containing the unique survey codes.

Use a Database Scripting Tool for PDF Automation
For advanced users, utilize a database and a programming language like Python to automate the overlay of unique text codes onto a base PDF template.
Create Unique Survey PDFs with WPS Office
Use WPS Spreadsheet to quickly generate thousands of unique survey codes, and seamlessly merge them into your survey documents using the powerful Mail Merge feature in WPS Writer. Export directly to PDF for effortless distribution.
- 1. Create a code list: Open WPS Spreadsheet, generate a list of 1,500 unique survey codes using formulas or sequential data, and save the file.
- 2. Open the survey template: Open your survey document in WPS Writer and navigate to the 'Mailings' tab.
- 3. Connect the data source: Click 'Open Data Source' and select the WPS Spreadsheet file containing your newly generated unique codes.
- 4. Insert the code field: Place your cursor on the welcome letter where the code should be displayed, and click 'Insert Merge Field' to insert your code column.
- 5. Export to PDF: Click 'Merge to Printer' and choose a PDF printer, or merge to a new document and use WPS Writer's built-in 'Export to PDF' feature to save your customized surveys.

Frequently Asked Questions
Can I use PDF barcode fields to generate unique printed codes?
No. A barcode form field in a PDF is designed to encode user-entered data from the form into a scannable format. It does not automatically generate unique text codes across different printed copies.
How do I generate random alphanumeric codes in a spreadsheet?
You can use combinations of built-in formulas, such as combining RANDBETWEEN() with CHAR() to generate random letters and numbers, or simply generate sequential numbers and append a prefix to them.
Is it possible to validate these printed codes online automatically?
Yes. Once you generate the unique codes in your spreadsheet or database, you must upload that exact list into your online survey platform (like SurveyMonkey or Qualtrics). The platform can then use that list to validate respondent entries.
How can I save each merged document as a separate PDF file?
While a standard mail merge often creates one large document, you can use third-party add-ins or specialized PDF printer software that splits the print job into individual PDF files based on page numbers or merged sections.




