How to Batch Convert Excel Data into Editable DOCX and Final PDF
Turn Excel rows into editable Word documents and matching PDFs in one local batch. Follow a complete free Excel VBA example with Word bookmarks, optional logo images, safe output names, and a practical verification checklist.
Quick answer
Keep your data in Excel and your layout in a Word template. For each populated row, an Excel VBA macro opens the template, fills named Word bookmarks, saves a separate editable .docx, then uses Word's ExportAsFixedFormat to create a matching .pdf. The PDF is for distribution; the DOCX stays available for revision.
RecordID C-1042 and date 2026-11-15 in Excel row 2 produce:
Output/WORD/C-1042_20261115_0002.docx
Output/PDF/C-1042_20261115_0002.pdf
Both files come from the same populated Word document and share an identifiable base name. The final _0002 is the Excel row number (row 2), not a collision suffix. If you run the same row again and the name is occupied, the macro adds _2 after it.
Why generate editable DOCX and PDF together?
The two formats serve different needs. A Word document is useful for later editing and approval; a PDF is convenient for sharing a fixed-layout representation after review. Generating both from the same record avoids a separate manual conversion pass.
Keep an editable working copy
The DOCX can be corrected, annotated or updated in Microsoft Word without rebuilding the entire batch from scratch.
Export the reviewed layout
The PDF is produced by Word from the populated document, reducing differences caused by separately copying data into another tool. Check fonts, images and page breaks before distribution.
Match each pair to Excel
Both files share the same filename stem, derived from the Excel record ID, document date and source row. A rerun gets a suffix rather than intentionally overwriting an earlier pair.
Keep processing local
This VBA uses Excel and Word Desktop on Windows, without sending workbook or template content to a third-party cloud service. It is not a digital-signature or document-versioning system.
What usually goes wrong
A two-format batch can fail even when the individual save commands look simple. Most errors come from inconsistent source fields, missing Word bookmarks or unmatched output filenames.
The script saves each row to Document.docx, exports the PDF under another name and ignores errors while inserting the optional logo. A second run can replace an earlier output.
Choose one available name for the DOCX/PDF pair, validate required Word bookmarks and source dates, and report any missing optional logos. Check the pair before distributing it.
If filenames are already being overwritten, see the dedicated duplicate-output fix. If you need column-driven output folders, read the Excel folder-routing guide.
Build the Excel → Word → PDF workflow
Prepare one workbook, one Word template and, if required, an images folder. Put the template and workbook in the same saved directory before running the macro.
Step 1: set up the Excel columns
Create a worksheet named Data with row-1 headers: A RecordID, B ClientName, C Address, D DocumentDate, E LogoFile (optional). Store actual Excel dates in column D.
Step 2: prepare the Word template
Save MasterTemplate.docx next to your workbook. Add three text bookmarks named ClientName, Address, and DocumentDate where those values should appear. Add photo_logo only if using a logo.
Step 3: run the free Excel VBA
Save the workbook as BatchData.xlsm. If using logos, create an Images folder beside the workbook and put the logo files there; enter only their filenames in column E. If you do not use logos, leave column E blank. Then run BatchExcelToEditableDocxAndPdf from an Excel VBA standard module.
Step 4: review both outputs
The macro creates Output/WORD and Output/PDF, then processes nonempty rows sequentially. Review document content, any missing-logo warnings, and matching DOCX/PDF pairs before sending PDFs.
BatchData.xlsm
MasterTemplate.docx
Images/logo-acme.png (optional)
Output/WORD/C-1042_20261115_0002.docx
Output/PDF/C-1042_20261115_0002.pdf
Test the pair before running a large batch
Use a small workbook with two sample records and a Word template containing the correct bookmarks. Confirm the following behaviors on your own Office installation.
Two populated rows
Enter C-1042 in A2 and C-1043 in A3, with valid dates in D2 and D3. Expect two editable Word documents and two PDFs with corresponding names.
Duplicate ID and second run
Repeat an ID, then run the workbook again without deleting outputs. Row numbers distinguish records in one pass; occupied DOCX or PDF names trigger _2, _3 and later suffixes.
Missing optional logo
Put a nonexistent filename in E2. The macro should create that row's document pair without the optional logo and show a warning. If a real logo is specified but the photo_logo bookmark is absent, it stops with an error.
Missing date or failed PDF
Leave D3 blank or use a text date: expect the batch to stop with the row number. If PDF export fails after DOCX save, inspect the output folder for a partial pair before rerunning.
Free Excel VBA: create editable DOCX and matching PDF
This complete example runs from the saved Excel workbook. It reads visible text for name and address fields, keeps the date from a real Excel date cell, fills Word bookmarks, optionally inserts an embedded logo, then saves both formats using one available base name.
Use Microsoft Excel and Word Desktop on Windows. Save BatchData.xlsm and MasterTemplate.docx together. The workbook needs a Data sheet with A–E columns as shown above; the template needs ClientName, Address, and DocumentDate bookmarks. If E contains logo filenames, first create Images/ beside the workbook, place the files there, and add the photo_logo bookmark to Word. Widen columns A, B, C, and E before running: the macro uses Excel .Text for these displayed values, which can produce unexpected text (including #### for narrow formatted cells). Enable macros only for workbooks you trust.
Option Explicit
' Run in a trusted Excel .xlsm workbook on Windows.
' Save MasterTemplate.docx next to the workbook.
' Use Data sheet: A=RecordID, B=ClientName, C=Address,
' D=DocumentDate (real Excel date), E=LogoFile (optional file name).
' Word bookmarks: ClientName, Address, DocumentDate;
' optional photo_logo for an image stored in the Images subfolder.
Public Sub BatchExcelToEditableDocxAndPdf()
Dim ws As Worksheet
Dim wdApp As Object, doc As Object
Dim rootFolder As String, templatePath As String
Dim imageFolder As String, wordFolder As String, pdfFolder As String
Dim lastRow As Long, rowNum As Long, colNum As Long
Dim recordID As String, dateStamp As String, stem As String
Dim candidate As String, docxPath As String, pdfPath As String
Dim logoName As String, logoPath As String
Dim suffix As Long, completed As Long, warningCount As Long
Dim warningText As String, errText As String
On Error GoTo Failed
If Len(ThisWorkbook.Path) = 0 Then
Err.Raise vbObjectError + 201, , "Save the Excel .xlsm file first."
End If
rootFolder = ThisWorkbook.Path
templatePath = rootFolder & "\MasterTemplate.docx"
imageFolder = rootFolder & "\Images"
wordFolder = rootFolder & "\Output\WORD"
pdfFolder = rootFolder & "\Output\PDF"
If Len(Dir$(templatePath)) = 0 Then
Err.Raise vbObjectError + 202, , "Missing template: " & templatePath
End If
EnsureDirectory rootFolder & "\Output"
EnsureDirectory wordFolder
EnsureDirectory pdfFolder
Set ws = ThisWorkbook.Worksheets("Data")
For colNum = 1 To 5
If ws.Cells(ws.Rows.Count, colNum).End(xlUp).Row > lastRow Then
lastRow = ws.Cells(ws.Rows.Count, colNum).End(xlUp).Row
End If
Next colNum
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = False
wdApp.DisplayAlerts = 0
For rowNum = 2 To lastRow
If Application.WorksheetFunction.CountA(ws.Range( _
ws.Cells(rowNum, 1), ws.Cells(rowNum, 5))) > 0 Then
recordID = SafeNamePart(CStr(ws.Cells(rowNum, 1).Text))
If Len(recordID) = 0 Then recordID = "Row_" & CStr(rowNum)
If Not IsNumeric(ws.Cells(rowNum, 4).Value2) Or _
Not IsDate(ws.Cells(rowNum, 4).Value) Then
Err.Raise vbObjectError + 203, , _
"DocumentDate in column D must be a real Excel date."
End If
dateStamp = Format$(CDate(ws.Cells(rowNum, 4).Value), "yyyymmdd")
stem = Left$(recordID, 65) & "_" & dateStamp & "_" & _
Format$(rowNum, "0000")
candidate = stem
suffix = 2
' Check both destinations before choosing one shared base name.
Do
docxPath = wordFolder & "\" & candidate & ".docx"
pdfPath = pdfFolder & "\" & candidate & ".pdf"
If Len(Dir$(docxPath)) = 0 And Len(Dir$(pdfPath)) = 0 Then Exit Do
candidate = stem & "_" & CStr(suffix)
suffix = suffix + 1
Loop
Set doc = wdApp.Documents.Open(FileName:=templatePath, _
ReadOnly:=True, _
AddToRecentFiles:=False)
PutTextAtBookmark doc, "ClientName", _
CStr(ws.Cells(rowNum, 2).Text)
PutTextAtBookmark doc, "Address", _
CStr(ws.Cells(rowNum, 3).Text)
PutTextAtBookmark doc, "DocumentDate", _
Format$(CDate(ws.Cells(rowNum, 4).Value), "yyyy-mm-dd")
logoName = Trim$(CStr(ws.Cells(rowNum, 5).Text))
If Len(logoName) > 0 Then
If InStr(logoName, "\") > 0 Or InStr(logoName, "/") > 0 Or _
InStr(logoName, ":") > 0 Then
Err.Raise vbObjectError + 204, , _
"LogoFile must be a file name, not a path."
End If
logoPath = imageFolder & "\" & logoName
If Len(Dir$(logoPath)) > 0 Then
PutPictureAtBookmark doc, "photo_logo", logoPath
Else
warningCount = warningCount + 1
If warningCount <= 5 Then
warningText = warningText & "Row " & rowNum & _
": missing logo " & logoName & vbCrLf
End If
End If
End If
doc.SaveAs2 FileName:=docxPath, FileFormat:=16, _
AddToRecentFiles:=False
doc.ExportAsFixedFormat OutputFileName:=pdfPath, _
ExportFormat:=17, OpenAfterExport:=False
doc.Close SaveChanges:=False
Set doc = Nothing
completed = completed + 1
End If
Next rowNum
errText = "Created " & completed & " DOCX/PDF pairs." & vbCrLf & _
"Output folders: " & rootFolder & "\Output"
If warningCount > 0 Then
errText = errText & vbCrLf & warningCount & _
" optional logo(s) missing:" & vbCrLf & warningText
If warningCount > 5 Then errText = errText & "...and more."
End If
MsgBox errText, IIf(warningCount > 0, vbExclamation, vbInformation)
GoTo Cleanup
Failed:
errText = Err.Description
If rowNum >= 2 Then errText = "Excel row " & rowNum & ": " & errText
MsgBox "Batch stopped after " & completed & " pair(s): " & errText & _
vbCrLf & "Check for a DOCX without a matching PDF.", vbExclamation
Cleanup:
On Error Resume Next
If Not doc Is Nothing Then doc.Close SaveChanges:=False
If Not wdApp Is Nothing Then wdApp.Quit SaveChanges:=False
Set doc = Nothing
Set wdApp = Nothing
Set ws = Nothing
On Error GoTo 0
End Sub
Private Sub EnsureDirectory(ByVal path As String)
If Len(Dir$(path, vbDirectory)) = 0 Then MkDir path
If (GetAttr(path) And vbDirectory) = 0 Then
Err.Raise vbObjectError + 205, , "Not a folder: " & path
End If
End Sub
Private Function SafeNamePart(ByVal source As String) As String
Dim s As String, bad As Variant, ch As Variant, k As Long
Dim basePart As String
s = Trim$(source)
bad = Array("\", "/", ":", "*", "?", Chr$(34), "<", ">", "|")
For Each ch In bad
s = Replace$(s, CStr(ch), "_")
Next ch
For k = 0 To 31
s = Replace$(s, Chr$(k), "_")
Next k
s = Left$(s, 70)
Do While Len(s) > 0
If Right$(s, 1) <> "." And Right$(s, 1) <> " " Then Exit Do
s = Left$(s, Len(s) - 1)
Loop
If Len(s) > 0 Then
basePart = UCase$(Split(s, ".")(0))
Select Case basePart
Case "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", _
"COM4", "COM5", "COM6", "COM7", "COM8", "COM9", _
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", _
"LPT7", "LPT8", "LPT9"
s = "_" & s
End Select
End If
SafeNamePart = s
End Function
Private Sub PutTextAtBookmark(ByVal doc As Object, _
ByVal name As String, ByVal value As String)
Dim rng As Object
If Not doc.Bookmarks.Exists(name) Then
Err.Raise vbObjectError + 206, , "Missing Word bookmark: " & name
End If
Set rng = doc.Bookmarks(name).Range
rng.Text = value
doc.Bookmarks.Add Name:=name, Range:=rng
End Sub
Private Sub PutPictureAtBookmark(ByVal doc As Object, _
ByVal name As String, ByVal picturePath As String)
Dim target As Object
If Not doc.Bookmarks.Exists(name) Then
Err.Raise vbObjectError + 207, , "Missing picture bookmark: " & name
End If
Set target = doc.Bookmarks(name).Range
doc.InlineShapes.AddPicture FileName:=picturePath, _
LinkToFile:=False, SaveWithDocument:=True, Range:=target
End Sub
The macro fills bookmarks in the main document, not all possible Word stories such as header/footer text boxes. For DOCX/PDF output Word is required; PDF export does not automatically sign or lock the PDF. This example is sequential and is not safe against simultaneous writers choosing the same destination.
Where the free VBA still has limits
The sample is suitable for learning and controlled local batches. Treat it as an example to test, not a substitute for validation, audit logging or recovery procedures on important documents.
Rendering is installation-dependent
DOCX and PDF use the same Word content, but missing fonts, printer settings, images or template layout can affect page breaks. Review output samples before distribution.
Images need explicit handling
A missing optional logo is reported and omitted; a failed image insertion or a missing expected bookmark stops the batch. Multiple photos, stamps and signatures need additional mapping and sizing code.
Partial outputs and reruns
PDF export can fail after the DOCX has been saved. The sample warns you to inspect the pair. The collision check protects sequential reruns, not simultaneous processes sharing one folder.
Speed varies by computer
Performance depends on the PC, storage, Word installation, template complexity, images and PDF rendering. Neither VBA nor DocxForge Pro guarantees a fixed number of files per minute.
To design stable filename patterns first, see how to organize output file names. For concurrent saves into shared folders, use the shared-folder overwrite guide.
Free VBA vs DocxForge Pro Factory
If one template and a small, predictable Excel sheet are enough, keep the free macro. DocxForge Pro Factory is useful for recurring Excel-driven Word/PDF work where configuring data fields and batch output in a desktop interface is more convenient than maintaining VBA.
Editable Word + optional PDF
Free VBA: saves both formats through Word code.
DocxForge Pro Factory: offers DOCX generation with optional PDF export from a local batch workflow.
Excel fields and Word templates
Free VBA: requires manually matching Excel column numbers to bookmarks.
DocxForge Pro Factory: previews imported Excel data and supports template tag workflows through its interface.
Photos and other fields
Free VBA: this example inserts one optional logo; additional image types require more code.
DocxForge Pro: text and photo tag workflows are available across its included desktop modules.
Who should choose which?
Use the macro for a limited, stable task. Consider DocxForge Pro Factory when maintaining templates, naming settings, and repeat batches has become ongoing work. Both solutions still depend on the available PC resources and Microsoft Office Desktop.
DocxForge Pro runs locally on Windows with Microsoft Word and Excel Desktop. The suite includes both Factory and DocxForge Pro Contractor, which focuses on reviewed case data and selected document sets. Compare available plans if a configurable workflow suits your needs.
Frequently asked questions
Answers about editable Word output, PDF export, optional images, and the limits of a local batch.
Can one Excel row create an editable DOCX and a PDF?
Yes. The macro opens one Word template per populated Excel row, fills it, saves a new editable DOCX and exports a PDF with the same filename stem.
Does the PDF always look exactly like the DOCX?
Word exports the PDF from the populated DOCX, but fonts, images, pagination and Word settings can affect the result. Review representative PDF files before distributing them.
What happens when two rows use the same record ID?
The example includes the source row in each name and checks both DOCX and PDF destinations. A rerun adds a numeric suffix instead of intentionally overwriting existing files. This is for sequential batches, not simultaneous writers.
What if the logo image is missing?
LogoFile is optional. If a named image cannot be found in the local Images folder, the macro records a visible warning and continues without that logo. Insertion errors or a missing required picture bookmark stop the batch.
Which Microsoft Office applications do I need?
The free example requires Microsoft Excel and Microsoft Word Desktop on Windows. The workbook must be saved as XLSM, and Word must be able to open the local DOCX template and export PDF.
Can the macro fill headers, footers, signatures or several templates?
Not without extending it. The example fills three text bookmarks and one optional logo bookmark in one template. Header/footer placeholders, multiple template sets, signatures and stamps need additional Word automation or a suitable configured workflow.