PDF Export in Word vs Browser-Based PDF Tools: Which Gives Better Control?
Choose the PDF engine by the approved source format, the layout features that must survive, the operating environment, and the evidence your team can reproduce.
Quick answer: keep the approved source native to its rendering engine
If the authoritative document is a DOCX with Word sections, styles, fields, headers, footers, and anchored objects, export it with Word Desktop. If the authoritative document is HTML/CSS built for paged media, use a tested browser or browser-based renderer. Rebuilding one format inside the other creates a second layout system to maintain.
DOCX source → Word PDF export. HTML/CSS source → browser PDF engine. Mixed workflow → define one canonical source, one controlled conversion boundary, and one release test set.
Compare control across six practical dimensions
Source fidelity
Word understands DOCX sections, Word styles, fields, footnotes, headers, footers, tables, and anchored objects. Browser engines understand HTML, CSS, web fonts, and print stylesheets.
Pagination
Word pagination follows the Word document model. Browser pagination follows CSS paged-media rules plus the chosen engine’s implementation and version.
Automation host
Word VBA can call ExportAsFixedFormat on Windows with Word Desktop. Browser export can run through a user interface, command-line browser, automation library, or hosted service.
Privacy boundary
A local engine can keep content on the machine. A hosted browser converter may upload it. “Browser-based” alone does not reveal where processing occurs.
Repeatability
Both approaches can be repeatable when versions, fonts, assets, settings, and test documents are controlled. Manual clicks without recorded settings weaken either workflow.
Handoff cost
Choose the format the team can maintain. A perfect pilot that depends on one person’s undocumented environment is not a controlled production process.
Where Word PDF export gives useful control
Word-native document structures
Keep section breaks, page numbering, Word tables, captions, cross-references, headers, footers, and other DOCX features in the engine that authored them.
Explicit fixed-format parameters
Choose print or screen optimization, export range, markup state, document properties, bookmarks, structure tags, missing-font behavior, and the PDF/A-1 switch.
Local operating boundary
Word Desktop can export locally without sending the document to an online converter. This does not remove the need to control local access, temporary files, and output folders.
Editable source and final PDF
Retain a reviewed DOCX beside the PDF so the team can distinguish the editable source from the released fixed-format output.
Where a browser PDF engine gives useful control
HTML and CSS are already canonical
A web-native report, invoice, portal page, or server-rendered template should usually remain in its tested HTML/CSS pipeline.
Cross-platform execution matters
A controlled browser engine can run on systems where Word Desktop is unavailable, provided the chosen fonts, assets, and browser version are fixed.
Web components are part of the design
Print stylesheets can deliberately hide navigation, restyle controls, define page size and margins, and convert responsive content into paged output.
Service deployment is required
A browser renderer can fit a server or container architecture more naturally than desktop automation. Confirm licensing, security, concurrency, and storage behavior.
Run one comparable pilot before choosing
Do not compare a mature DOCX template with a hurried HTML reconstruction, or a polished HTML report with an imported Word copy. Use equivalent approved content and record the work required to maintain each source.
1. Freeze the test content
Use the same text, data, images, page target, links, headings, and release requirements.
2. Define acceptance criteria
List page count, line breaks, tables, bookmarks, links, metadata, tags, image quality, and accessibility checks.
3. Record the environment
Capture Word or browser version, operating system, fonts, locale, export settings, and whether processing is local or remote.
4. Export three times
Repeat on the same controlled machine and confirm that file count, pages, layout, and required PDF features remain stable.
5. Change one difficult input
Test a long name, a longer table, a missing optional image, a new section, and a page-breaking paragraph.
6. Measure maintenance
Record how long it takes to update the source, fix a layout defect, reproduce the output, and hand the process to another operator.
Free Word VBA gate: export with explicit settings and a manifest
Store the macro in a trusted global template or add-in, open the approved saved DOCX, and run ExportControlledWordPdf. The original document is not modified. The macro creates an isolated DOCX copy, a PDF, and a text manifest inside a unique run folder.
Saved-state contract
The source must be a saved DOCX with no pending edits. The macro refuses unresolved tracked revisions and comments.
Linked-picture gate
Linked inline and floating pictures stop the export. Embed them first so the PDF does not depend on an external image path.
Predictable print options
Backgrounds and drawing objects are enabled. Field codes and hidden text are not printed, and fields or links are not silently refreshed at export time.
Pagination checkpoint
The copied DOCX is saved, closed, reopened read-only, and repaginated. A changed page count stops the run before PDF export.
Explicit PDF parameters
The example exports all document content for print, includes properties and structure tags, creates heading bookmarks, bitmaps missing fonts when needed, and leaves PDF/A disabled.
Evidence boundary
The manifest records source size and modification time, pages, observed fields, and export settings. It is not a file hash, visual approval, or accessibility conformance report.
Option Explicit
Private Const WORD_EXPORT_FORMAT_PDF As Long = 17
Private Const WORD_EXPORT_OPTIMIZE_FOR_PRINT As Long = 0
Private Const WORD_EXPORT_ALL_DOCUMENT As Long = 0
Private Const WORD_EXPORT_DOCUMENT_CONTENT As Long = 0
Private Const WORD_EXPORT_CREATE_HEADING_BOOKMARKS As Long = 1
Private Const WORD_STATISTIC_PAGES As Long = 2
Private Const WORD_DO_NOT_SAVE_CHANGES As Long = 0
Private Const WORD_ALERTS_NONE As Long = 0
Private Const WORD_INLINE_LINKED_PICTURE As Long = 4
Private Const OFFICE_LINKED_PICTURE As Long = 11
Private Const USE_PDF_A As Boolean = False
Public Sub ExportControlledWordPdf()
Dim sourceDoc As Document
Dim workingDoc As Document
Dim fso As Object
Dim sourceFile As Object
Dim sourcePath As String
Dim sourceName As String
Dim baseName As String
Dim outputRoot As String
Dim runFolder As String
Dim workingFolder As String
Dim completedFolder As String
Dim workingDocxPath As String
Dim workingPdfPath As String
Dim workingManifestPath As String
Dim finalDocxPath As String
Dim finalPdfPath As String
Dim finalManifestPath As String
Dim pageCountBefore As Long
Dim pageCountAfter As Long
Dim fieldCount As Long
Dim previousScreenUpdating As Boolean
Dim previousDisplayAlerts As Long
Dim previousPrintBackgrounds As Boolean
Dim previousPrintDrawingObjects As Boolean
Dim previousPrintFieldCodes As Boolean
Dim previousPrintHiddenText As Boolean
Dim previousPrintComments As Boolean
Dim previousUpdateFieldsAtPrint As Boolean
Dim previousUpdateLinksAtPrint As Boolean
Dim appStateCaptured As Boolean
Dim optionStateCaptured As Boolean
Dim currentStep As String
Dim errorNumber As Long
Dim errorDescription As String
On Error GoTo CleanFail
Set sourceDoc = ActiveDocument
previousScreenUpdating = Application.ScreenUpdating
previousDisplayAlerts = Application.DisplayAlerts
appStateCaptured = True
Application.ScreenUpdating = False
Application.DisplayAlerts = WORD_ALERTS_NONE
previousPrintBackgrounds = Options.PrintBackgrounds
previousPrintDrawingObjects = Options.PrintDrawingObjects
previousPrintFieldCodes = Options.PrintFieldCodes
previousPrintHiddenText = Options.PrintHiddenText
previousPrintComments = Options.PrintComments
previousUpdateFieldsAtPrint = Options.UpdateFieldsAtPrint
previousUpdateLinksAtPrint = Options.UpdateLinksAtPrint
optionStateCaptured = True
Options.PrintBackgrounds = True
Options.PrintDrawingObjects = True
Options.PrintFieldCodes = False
Options.PrintHiddenText = False
Options.UpdateFieldsAtPrint = False
Options.UpdateLinksAtPrint = False
currentStep = "checking the saved source DOCX"
RequireSavedDocx sourceDoc
RequireReleaseState sourceDoc
RequireNoLinkedPictures sourceDoc
sourcePath = sourceDoc.FullName
sourceName = sourceDoc.Name
baseName = Left$(sourceName, Len(sourceName) - 5)
ValidateFileStem baseName
sourceDoc.Repaginate
pageCountBefore = sourceDoc.ComputeStatistics(WORD_STATISTIC_PAGES)
If pageCountBefore < 1 Then
Err.Raise vbObjectError + 4800, , _
"Word reported no printable pages in the source document."
End If
fieldCount = CountFieldsAcrossStories(sourceDoc)
Set fso = CreateObject("Scripting.FileSystemObject")
Set sourceFile = fso.GetFile(sourcePath)
outputRoot = JoinPath(sourceDoc.Path, "ControlledPdfExports")
EnsureFolder outputRoot
runFolder = CreateRunFolder(fso, outputRoot)
workingFolder = JoinPath(runFolder, "Working")
completedFolder = JoinPath(runFolder, "Completed")
fso.CreateFolder workingFolder
fso.CreateFolder completedFolder
workingDocxPath = JoinPath(workingFolder, baseName & _
"_controlled.docx")
workingPdfPath = JoinPath(workingFolder, baseName & _
"_controlled.pdf")
workingManifestPath = JoinPath(workingFolder, _
"ExportManifest.txt")
finalDocxPath = JoinPath(completedFolder, baseName & _
"_controlled.docx")
finalPdfPath = JoinPath(completedFolder, baseName & _
"_controlled.pdf")
finalManifestPath = JoinPath(completedFolder, _
"ExportManifest.txt")
currentStep = "copying the approved saved DOCX"
fso.CopyFile sourcePath, workingDocxPath, False
RequireNonemptyFile workingDocxPath, "working DOCX copy"
currentStep = "opening and saving the isolated DOCX copy"
Set workingDoc = Documents.Open( _
FileName:=workingDocxPath, _
ConfirmConversions:=False, _
ReadOnly:=False, _
AddToRecentFiles:=False, _
Visible:=False)
RequireReleaseState workingDoc
RequireNoLinkedPictures workingDoc
workingDoc.Save
workingDoc.Close WORD_DO_NOT_SAVE_CHANGES
Set workingDoc = Nothing
currentStep = "reopening and verifying pagination"
Set workingDoc = Documents.Open( _
FileName:=workingDocxPath, _
ConfirmConversions:=False, _
ReadOnly:=True, _
AddToRecentFiles:=False, _
Visible:=False)
RequireReleaseState workingDoc
RequireNoLinkedPictures workingDoc
workingDoc.Repaginate
pageCountAfter = workingDoc.ComputeStatistics(WORD_STATISTIC_PAGES)
If pageCountAfter <> pageCountBefore Then
Err.Raise vbObjectError + 4801, , _
"Page count changed after copy, save, and reopen: " & _
pageCountBefore & " to " & pageCountAfter & "."
End If
currentStep = "exporting PDF with explicit Word settings"
RequireTargetAbsent workingPdfPath
workingDoc.ExportAsFixedFormat _
OutputFileName:=workingPdfPath, _
ExportFormat:=WORD_EXPORT_FORMAT_PDF, _
OpenAfterExport:=False, _
OptimizeFor:=WORD_EXPORT_OPTIMIZE_FOR_PRINT, _
Range:=WORD_EXPORT_ALL_DOCUMENT, _
From:=1, _
To:=1, _
Item:=WORD_EXPORT_DOCUMENT_CONTENT, _
IncludeDocProps:=True, _
KeepIRM:=True, _
CreateBookmarks:=WORD_EXPORT_CREATE_HEADING_BOOKMARKS, _
DocStructureTags:=True, _
BitmapMissingFonts:=True, _
UseISO19005_1:=USE_PDF_A
workingDoc.Close WORD_DO_NOT_SAVE_CHANGES
Set workingDoc = Nothing
RequireNonemptyFile workingPdfPath, "controlled PDF"
currentStep = "writing the export manifest"
WriteExportManifest fso, workingManifestPath, sourcePath, _
sourceFile.Size, sourceFile.DateLastModified, pageCountAfter, _
fieldCount
RequireNonemptyFile workingManifestPath, "export manifest"
currentStep = "committing the controlled export files"
RequireTargetAbsent finalDocxPath
RequireTargetAbsent finalPdfPath
RequireTargetAbsent finalManifestPath
Name workingDocxPath As finalDocxPath
Name workingPdfPath As finalPdfPath
Name workingManifestPath As finalManifestPath
RemoveEmptyFolder workingFolder
RestoreApplicationState appStateCaptured, optionStateCaptured, _
previousScreenUpdating, previousDisplayAlerts, _
previousPrintBackgrounds, previousPrintDrawingObjects, _
previousPrintFieldCodes, previousPrintHiddenText, _
previousPrintComments, _
previousUpdateFieldsAtPrint, previousUpdateLinksAtPrint
appStateCaptured = False
optionStateCaptured = False
MsgBox "Controlled Word PDF export created." & vbCrLf & _
"Pages: " & pageCountAfter & vbCrLf & _
"DOCX: " & finalDocxPath & vbCrLf & _
"PDF: " & finalPdfPath & vbCrLf & _
"Manifest: " & finalManifestPath & vbCrLf & vbCrLf & _
"Open the PDF and complete the visual and accessibility review.", _
vbInformation
CleanExit:
On Error Resume Next
If Not workingDoc Is Nothing Then _
workingDoc.Close WORD_DO_NOT_SAVE_CHANGES
RestoreApplicationState appStateCaptured, optionStateCaptured, _
previousScreenUpdating, previousDisplayAlerts, _
previousPrintBackgrounds, previousPrintDrawingObjects, _
previousPrintFieldCodes, previousPrintHiddenText, _
previousPrintComments, _
previousUpdateFieldsAtPrint, previousUpdateLinksAtPrint
Set workingDoc = Nothing
Set sourceDoc = Nothing
Set sourceFile = Nothing
Set fso = Nothing
On Error GoTo 0
Exit Sub
CleanFail:
errorNumber = Err.Number
errorDescription = Err.Description
On Error Resume Next
If Not workingDoc Is Nothing Then _
workingDoc.Close WORD_DO_NOT_SAVE_CHANGES
RestoreApplicationState appStateCaptured, optionStateCaptured, _
previousScreenUpdating, previousDisplayAlerts, _
previousPrintBackgrounds, previousPrintDrawingObjects, _
previousPrintFieldCodes, previousPrintHiddenText, _
previousPrintComments, _
previousUpdateFieldsAtPrint, previousUpdateLinksAtPrint
Set workingDoc = Nothing
Set sourceDoc = Nothing
Set sourceFile = Nothing
Set fso = Nothing
On Error GoTo 0
MsgBox "Export stopped while " & currentStep & "." & vbCrLf & _
"Error " & errorNumber & ": " & errorDescription & vbCrLf & _
IIf(Len(runFolder) > 0, _
"Inspect the retained run folder: " & runFolder, _
"No run folder was created.") & vbCrLf & _
"The source DOCX and existing output files were not changed.", _
vbCritical
End Sub
Private Sub RequireSavedDocx(ByVal doc As Document)
If Len(doc.Path) = 0 Then
Err.Raise vbObjectError + 4802, , _
"Save the source document as DOCX before export."
End If
If Not doc.Saved Then
Err.Raise vbObjectError + 4803, , _
"Save all source-document changes before export."
End If
If LCase$(Right$(doc.Name, 5)) <> ".docx" Then
Err.Raise vbObjectError + 4804, , _
"The source document must use the .docx format."
End If
RequireNonemptyFile doc.FullName, "source DOCX"
End Sub
Private Sub RequireReleaseState(ByVal doc As Document)
If doc.Revisions.Count > 0 Then
Err.Raise vbObjectError + 4805, , _
"Resolve all tracked revisions before controlled PDF export."
End If
If doc.Comments.Count > 0 Then
Err.Raise vbObjectError + 4806, , _
"Resolve or remove all comments before controlled PDF export."
End If
End Sub
Private Sub RequireNoLinkedPictures(ByVal doc As Document)
Dim rootStory As Range
Dim currentStory As Range
Dim inlineItem As InlineShape
Dim shapeItem As Shape
Dim sectionItem As Section
Dim headerFooterIndex As Long
Dim headerFooterItem As HeaderFooter
Dim uniqueShapes As Object
Dim shapeKey As Variant
Dim linkedCount As Long
Set uniqueShapes = CreateObject("Scripting.Dictionary")
uniqueShapes.CompareMode = vbBinaryCompare
For Each rootStory In doc.StoryRanges
Set currentStory = rootStory
Do While Not currentStory Is Nothing
For Each inlineItem In currentStory.InlineShapes
If inlineItem.Type = WORD_INLINE_LINKED_PICTURE Then
linkedCount = linkedCount + 1
End If
Next inlineItem
Set currentStory = currentStory.NextStoryRange
Loop
Next rootStory
For Each shapeItem In doc.Shapes
AddUniqueShape shapeItem, uniqueShapes
Next shapeItem
For Each sectionItem In doc.Sections
For headerFooterIndex = 1 To 3
Set headerFooterItem = sectionItem.Headers(headerFooterIndex)
If headerFooterItem.Exists Then
For Each shapeItem In headerFooterItem.Shapes
AddUniqueShape shapeItem, uniqueShapes
Next shapeItem
End If
Set headerFooterItem = sectionItem.Footers(headerFooterIndex)
If headerFooterItem.Exists Then
For Each shapeItem In headerFooterItem.Shapes
AddUniqueShape shapeItem, uniqueShapes
Next shapeItem
End If
Next headerFooterIndex
Next sectionItem
For Each shapeKey In uniqueShapes.Keys
Set shapeItem = uniqueShapes.Item(shapeKey)
If shapeItem.Type = OFFICE_LINKED_PICTURE Then
linkedCount = linkedCount + 1
End If
Next shapeKey
If linkedCount > 0 Then
Err.Raise vbObjectError + 4807, , _
"The document contains " & linkedCount & _
" linked picture(s). Embed or remove them before export."
End If
End Sub
Private Sub AddUniqueShape(ByVal shapeItem As Shape, _
ByVal uniqueShapes As Object)
Dim shapeKey As String
shapeKey = CStr(shapeItem.ID)
If Not uniqueShapes.Exists(shapeKey) Then
uniqueShapes.Add shapeKey, shapeItem
End If
End Sub
Private Function CountFieldsAcrossStories(ByVal doc As Document) As Long
Dim rootStory As Range
Dim currentStory As Range
For Each rootStory In doc.StoryRanges
Set currentStory = rootStory
Do While Not currentStory Is Nothing
CountFieldsAcrossStories = CountFieldsAcrossStories + _
currentStory.Fields.Count
Set currentStory = currentStory.NextStoryRange
Loop
Next rootStory
End Function
Private Sub WriteExportManifest(ByVal fso As Object, _
ByVal manifestPath As String, _
ByVal sourcePath As String, _
ByVal sourceSize As Double, _
ByVal sourceModified As Date, _
ByVal pageCount As Long, _
ByVal fieldCount As Long)
Dim stream As Object
RequireTargetAbsent manifestPath
Set stream = fso.CreateTextFile(manifestPath, False, True)
stream.WriteLine "CONTROLLED WORD PDF EXPORT"
stream.WriteLine "Created=" & Format$(Now, "yyyy-mm-dd hh:nn:ss")
stream.WriteLine "SourcePath=" & sourcePath
stream.WriteLine "SourceBytes=" & Format$(sourceSize, "0")
stream.WriteLine "SourceModified=" & _
Format$(sourceModified, "yyyy-mm-dd hh:nn:ss")
stream.WriteLine "Pages=" & pageCount
stream.WriteLine "FieldsObserved=" & fieldCount
stream.WriteLine "ExportFormat=PDF"
stream.WriteLine "OptimizeFor=Print"
stream.WriteLine "Range=AllDocument"
stream.WriteLine "Item=DocumentContent"
stream.WriteLine "IncludeDocProps=True"
stream.WriteLine "KeepIRM=True"
stream.WriteLine "CreateBookmarks=HeadingBookmarks"
stream.WriteLine "DocStructureTags=True"
stream.WriteLine "BitmapMissingFonts=True"
stream.WriteLine "UseISO19005_1=" & CStr(USE_PDF_A)
stream.WriteLine "UpdateFieldsAtPrint=False"
stream.WriteLine "UpdateLinksAtPrint=False"
stream.WriteLine "VisualReviewRequired=True"
stream.Close
End Sub
Private Sub RestoreApplicationState( _
ByVal appStateCaptured As Boolean, _
ByVal optionStateCaptured As Boolean, _
ByVal previousScreenUpdating As Boolean, _
ByVal previousDisplayAlerts As Long, _
ByVal previousPrintBackgrounds As Boolean, _
ByVal previousPrintDrawingObjects As Boolean, _
ByVal previousPrintFieldCodes As Boolean, _
ByVal previousPrintHiddenText As Boolean, _
ByVal previousPrintComments As Boolean, _
ByVal previousUpdateFieldsAtPrint As Boolean, _
ByVal previousUpdateLinksAtPrint As Boolean)
On Error Resume Next
If optionStateCaptured Then
Options.PrintBackgrounds = previousPrintBackgrounds
Options.PrintDrawingObjects = previousPrintDrawingObjects
Options.PrintFieldCodes = previousPrintFieldCodes
Options.PrintHiddenText = previousPrintHiddenText
Options.PrintComments = previousPrintComments
Options.UpdateFieldsAtPrint = previousUpdateFieldsAtPrint
Options.UpdateLinksAtPrint = previousUpdateLinksAtPrint
End If
If appStateCaptured Then
Application.DisplayAlerts = previousDisplayAlerts
Application.ScreenUpdating = previousScreenUpdating
End If
On Error GoTo 0
End Sub
Private Function CreateRunFolder(ByVal fso As Object, _
ByVal outputRoot As String) As String
Dim baseFolder As String
Dim candidate As String
Dim suffix As Long
baseFolder = "Run_" & Format$(Now, "yyyymmdd_hhnnss")
candidate = JoinPath(outputRoot, baseFolder)
Do While fso.FolderExists(candidate)
suffix = suffix + 1
candidate = JoinPath(outputRoot, baseFolder & "_" & _
Format$(suffix, "000"))
Loop
fso.CreateFolder candidate
CreateRunFolder = candidate
End Function
Private Sub EnsureFolder(ByVal folderPath As String)
If FolderExistsStrict(folderPath) Then Exit Sub
On Error GoTo CreateFailed
MkDir folderPath
Exit Sub
CreateFailed:
Err.Raise vbObjectError + 4808, , _
"Could not create folder: " & folderPath & ". " & Err.Description
End Sub
Private Sub RequireTargetAbsent(ByVal filePath As String)
If FileExistsStrict(filePath) Then
Err.Raise vbObjectError + 4809, , _
"Refusing to overwrite existing file: " & filePath
End If
End Sub
Private Sub RequireNonemptyFile(ByVal filePath As String, _
ByVal fileLabel As String)
If Not FileExistsStrict(filePath) Then
Err.Raise vbObjectError + 4810, , _
"Missing " & fileLabel & ": " & filePath
End If
On Error GoTo SizeFailed
If FileLen(filePath) <= 0 Then
Err.Raise vbObjectError + 4811, , _
"Empty " & fileLabel & ": " & filePath
End If
Exit Sub
SizeFailed:
If Err.Number >= vbObjectError + 4810 And _
Err.Number <= vbObjectError + 4811 Then
Err.Raise Err.Number, , Err.Description
End If
Err.Raise vbObjectError + 4812, , _
"Could not inspect " & fileLabel & ": " & filePath & _
". " & Err.Description
End Sub
Private Function FileExistsStrict(ByVal filePath As String) As Boolean
Dim resultText As String
On Error GoTo CheckFailed
resultText = Dir$(filePath, vbNormal Or vbHidden Or vbSystem Or vbReadOnly)
FileExistsStrict = (Len(resultText) > 0)
Exit Function
CheckFailed:
Err.Raise vbObjectError + 4813, , _
"Could not check file path: " & filePath & ". " & Err.Description
End Function
Private Function FolderExistsStrict(ByVal folderPath As String) As Boolean
Dim resultText As String
On Error GoTo CheckFailed
resultText = Dir$(folderPath, vbDirectory)
If Len(resultText) = 0 Then
FolderExistsStrict = False
Else
FolderExistsStrict = _
((GetAttr(folderPath) And vbDirectory) = vbDirectory)
End If
Exit Function
CheckFailed:
Err.Raise vbObjectError + 4814, , _
"Could not check folder path: " & folderPath & ". " & Err.Description
End Function
Private Sub RemoveEmptyFolder(ByVal folderPath As String)
On Error GoTo RemoveFailed
If Not FolderExistsStrict(folderPath) Then Exit Sub
If Len(Dir$(JoinPath(folderPath, "*"), _
vbNormal Or vbHidden Or vbSystem Or vbReadOnly Or vbDirectory)) > 0 Then _
Exit Sub
RmDir folderPath
Exit Sub
RemoveFailed:
Err.Raise vbObjectError + 4815, , _
"Could not remove empty working folder: " & folderPath & _
". " & Err.Description
End Sub
Private Function JoinPath(ByVal parentPath As String, _
ByVal childName As String) As String
If Right$(parentPath, 1) = "\" Then
JoinPath = parentPath & childName
Else
JoinPath = parentPath & "\" & childName
End If
End Function
Private Sub ValidateFileStem(ByVal fileStem As String)
Dim invalidCharacters As Variant
Dim invalidCharacter As Variant
Dim baseName As String
If Len(fileStem) = 0 Or Len(fileStem) > 120 Then
Err.Raise vbObjectError + 4816, , _
"The source filename stem must contain 1 to 120 characters."
End If
If fileStem <> Trim$(fileStem) Then
Err.Raise vbObjectError + 4817, , _
"The source filename stem has outer whitespace."
End If
invalidCharacters = Array("<", ">", ":", Chr$(34), "/", "\", _
"|", "?", "*")
For Each invalidCharacter In invalidCharacters
If InStr(1, fileStem, CStr(invalidCharacter), vbBinaryCompare) > 0 Then
Err.Raise vbObjectError + 4818, , _
"The source filename contains a forbidden Windows character."
End If
Next invalidCharacter
If ContainsControlCharacter(fileStem) Then
Err.Raise vbObjectError + 4819, , _
"The source filename contains a control character."
End If
If Right$(fileStem, 1) = "." Or Right$(fileStem, 1) = " " Then
Err.Raise vbObjectError + 4820, , _
"The source filename cannot end with a period or space."
End If
baseName = fileStem
If InStr(1, baseName, ".", vbBinaryCompare) > 0 Then
baseName = Left$(baseName, InStr(1, baseName, ".", _
vbBinaryCompare) - 1)
End If
If IsReservedWindowsName(baseName) Then
Err.Raise vbObjectError + 4821, , _
"The source filename uses a reserved Windows name."
End If
End Sub
Private Function ContainsControlCharacter(ByVal valueText As String) As Boolean
Dim characterIndex As Long
Dim characterCode As Long
For characterIndex = 1 To Len(valueText)
characterCode = AscW(Mid$(valueText, characterIndex, 1))
If characterCode >= 0 And characterCode <= 31 Then
ContainsControlCharacter = True
Exit Function
End If
Next characterIndex
End Function
Private Function IsReservedWindowsName(ByVal baseName As String) As Boolean
Dim upperName As String
Dim suffixText As String
Dim suffixCode As Long
upperName = UCase$(baseName)
Select Case upperName
Case "CON", "PRN", "AUX", "NUL", "CLOCK$"
IsReservedWindowsName = True
Exit Function
End Select
If Len(upperName) >= 4 Then
If Left$(upperName, 3) = "COM" Or Left$(upperName, 3) = "LPT" Then
suffixText = Mid$(upperName, 4)
If Len(suffixText) = 1 Then
suffixCode = AscW(suffixText)
If (suffixCode >= AscW("1") And suffixCode <= AscW("9")) Or _
suffixText = ChrW$(&HB9) Or _
suffixText = ChrW$(&HB2) Or _
suffixText = ChrW$(&HB3) Then
IsReservedWindowsName = True
End If
End If
End If
End If
End FunctionMicrosoft documents the available parameters for Document.ExportAsFixedFormat and the global behaviors behind UpdateLinksAtPrint. For HTML sources, the W3C CSS Paged Media specification defines the page model, while actual browser support still needs testing in the chosen engine.
Interpret the pilot without declaring a universal winner
Choose Word when DOCX is authoritative
Prefer it when the team edits Word templates, depends on Word-native structures, needs editable DOCX output, and can control Word Desktop.
Choose a browser engine when HTML is authoritative
Prefer it when the team owns HTML/CSS, deploys web or server workflows, and can test one browser build and its paged-media behavior.
Keep both only with a real boundary
A hybrid architecture needs a documented canonical source for each document type. Avoid maintaining the same layout independently in DOCX and HTML without a business reason.
Reject both when requirements are unmet
If neither pilot meets accessibility, archival, signature, security, performance, or fidelity requirements, choose a specialized renderer or document service and test it separately.
Keep the comparison honest
No pixel-perfect guarantee
Neither route guarantees identical output across every machine, version, font set, and viewer.
No automatic field approval
The VBA does not update fields. Update, review, and save the authoritative values before export.
No exhaustive link audit
The helper checks linked pictures in common Word stories and header/footer shapes, not every possible OLE object, field, media type, or add-in.
No accessibility certification
Structure tags and heading bookmarks can help, but the macro does not prove PDF/UA or WCAG conformance.
No atomic three-file commit
DOCX, PDF, and manifest move separately. A failure between moves can leave files split between Working and Completed for manual reconciliation.
No browser security assumption
Check whether the chosen browser tool is local or hosted and verify its data handling instead of inferring privacy from the interface.
Use the DocxForge Pro module that matches the Word workflow
DocxForge Pro is a local Word-template workflow that requires Microsoft Word Desktop. It keeps editable DOCX and final PDF output in a Word-centered process; it does not render HTML/CSS through a browser engine.
Contractor: one case, several different documents
Review one case dataset, then create several different documents for that case from different Word templates. Use it for a coordinated pack whose documents share the same approved case data.
Factory: many rows, one standard template
Apply one standard Word template to many independent Excel rows. Every selected row creates a separate document for the same repeatable document type.
Use another tested pipeline when HTML/CSS is the canonical source, Word Desktop is unavailable, or the output requires a server-native renderer. DocxForge Pro does not replace PDF accessibility, archival, signature, or visual release checks.
Contractor: one reviewed case across different Word templates
Review shared case data, then select the different documents required for the pack.


Factory: independent Excel rows through one Word template
Review the selected rows, then apply the same standard template to the batch.


Frequently asked questions
Which option gives better PDF control?
Use the engine that matches the approved source. Word usually gives more predictable control for DOCX-native layouts with sections, headers, footers, fields, and Word styles. A browser engine is the natural choice for an HTML/CSS source designed and tested for paged media. Neither engine is universally more accurate.
Does a browser-based PDF tool always upload the document?
No. Some tools run locally, some use a local browser with automation, and others upload content to a remote service. Verify the specific product’s data flow, retention, region, access controls, and offline behavior before using confidential material.
Does Word PDF export guarantee an identical result on every computer?
No. Word version, fonts, linked assets, printer-related layout behavior, document corruption, and policy can affect pagination or rendering. Use a controlled machine, explicit export settings, a fixed test set, and visual review of the resulting PDF.
Does the VBA helper update fields or linked content automatically?
No. It deliberately exports the saved document state, disables field and link updates during export, and stops when it finds tracked revisions, comments, or linked pictures. Update and approve fields before saving the source DOCX.
Does the VBA example create PDF/A?
No. USE_PDF_A is set to False. Change that only when your retention requirement calls for the ISO 19005-1 subset, then validate the resulting file and visual output against the applicable policy.
Where does DocxForge Pro fit in this comparison?
DocxForge Pro is a local Word-template workflow that requires Microsoft Word Desktop. Contractor creates several different documents for one reviewed case from different Word templates. Factory applies one standard Word template to many independent Excel rows and creates a separate output for each selected row. It is not an HTML-to-PDF browser engine.