Document Types & Use Cases

How to Automate Incident Reports with Photos and Signatures

Build a controlled Factory workflow in which each approved Excel row creates one standard incident report with document-ready text, an evidence photo, and an authorized signature image when applicable.

One row per incident
Evidence photo
Authorized signature image
DOCX + PDF review
An image of a signature is not a digital signature or proof of signer authorization. Approve its use separately before releasing a report.

Quick answer: use one controlled row-to-report contract

Excel owns the incident record

Keep one row per independent incident with a stable ID, document-ready date, site, reporter, factual summary, asset filenames, review status, and output name.

Word owns the approved report layout

Use one standard template for headings, fixed notices, field destinations, photo and signature areas, page geometry, and reviewer-facing output.

Factory boundary

This article covers many independent incident rows through one standard template. A case that produces several different documents from different templates belongs in Contractor.

Define the incident-report contract before automating it

Record identity

Assign one immutable IncidentID. Do not use a row number as the long-term identifier.

Factual source text

Separate observed facts from conclusions, corrective actions, or legal characterizations that require review.

Evidence asset

Reference a controlled photo filename and preserve the original evidence outside the generated document.

Signature authorization

Record YES or NO separately from the image filename. Possession of an image file is not authorization to use it.

Release status

Generate only READY rows. HOLD means the record still requires correction, evidence, authorization, or review.

Output identity

Give each row a unique, safe OutputName and block silent overwrites in the production workflow.

Create the Excel source in one exact A–J order

Required column order (row 1): A — IncidentID; B — IncidentDateDisplay; C — SiteName; D — ReporterName; E — IncidentSummary; F — PhotoFile; G — SignatureFile; H — SignatureAuthorized; I — ReportStatus; J — OutputName.

A–B: identity and date

Format IncidentID as Text before importing IDs with leading zeros. Store IncidentDateDisplay as approved document-ready text.

C–E: report text

Keep site, reporter, and summary values free of tabs and manual line breaks unless the template contract explicitly supports them.

F–G: filenames only

Use filenames such as INC-0042-photo.jpg, not absolute paths. Put approved files in IncidentAssets beside the workbook.

H: explicit authorization

Use YES only when the signature image is approved for this workflow. Use NO and leave SignatureFile blank otherwise.

I: controlled release state

Use READY or HOLD exactly. Do not turn missing approval into a blank value that another step may misread.

J: safe output stem

Store a filename stem without .docx or .pdf; validate reserved names, forbidden characters, length, and duplicates.

Excel technical reference: Range.Value2. The helper deliberately requires the date display field to be stored as text rather than relying on a formatted numeric date.

Treat photos and signatures as controlled assets

Preserve originals

Do not resize, crop, rename, or overwrite the only copy of an evidence photo. Generate from an approved working copy.

Keep a fixed asset root

Resolve filenames only inside IncidentAssets. Reject absolute paths, subfolders, and .. traversal in this simple contract.

Allow known image types

Use JPG, JPEG, or PNG and verify that each file exists and is non-empty before generation begins. Extension and size checks do not authenticate the file or prove its actual image format.

Embed final images

For portable output, insert the approved image into Word instead of leaving a link that can break on another computer.

Constrain display size

Define maximum photo and signature dimensions in the template contract and preserve aspect ratio.

Separate authorization evidence

Keep the approval record, signer identity, and release decision outside the bitmap itself.

Word technical references: InlineShapes.AddPicture and Document.ExportAsFixedFormat.

Build one standard Word template for every READY row

Fixed report structure

Keep the approved title, section order, labels, notices, review lines, and footer in Word.

Declared destinations

Define exact tags or bookmarks for every source field, the evidence photo, and the optional signature image.

Required photo destination

The template destination is required even when a later policy permits a specific report to omit a photo.

Optional signature result

The template may reserve a signature area, but insert an image only when authorization is YES and the approved file passes preflight.

Stable image layout

Use predictable inline placement, fixed table widths, and tested maximum dimensions.

Reviewer-visible status

Do not hide uncertainty. Route HOLD records and failed assets back to review instead of generating a plausible-looking report.

Free VBA helper: audit incident rows before generation

Save a writable copy as an Excel Macro-Enabled Workbook (.xlsm). Create the Incidents sheet in the exact A–J order above and an IncidentAssets folder beside the workbook. This helper creates a timestamped audit sheet; it does not open Word or generate reports.

Source contract

Checks exact headers, required values, document-ready date text, tabs, line breaks, status, and authorization values.

Identity and filenames

Checks exact duplicate IDs, case-insensitive duplicate output names, forbidden characters, length, and Windows device names.

Asset boundary

Rejects unsafe Windows filenames, keeps files inside IncidentAssets, and verifies the allowed extension, existence, and non-zero size. It does not authenticate image content.

Signature rule

Requires a file for YES, rejects a file for NO, and rejects a photo and signature that resolve to the same asset.

Excel VBA — incident source and asset auditPreflight only
Option Explicit

Private Const DATA_SHEET As String = "Incidents"
Private Const AUDIT_PREFIX As String = "IncidentAudit_"
Private Const ASSET_FOLDER As String = "\IncidentAssets"
Private Const FIRST_DATA_ROW As Long = 2

Private Const COL_INCIDENT_ID As Long = 1
Private Const COL_INCIDENT_DATE As Long = 2
Private Const COL_SITE_NAME As Long = 3
Private Const COL_REPORTER_NAME As Long = 4
Private Const COL_SUMMARY As Long = 5
Private Const COL_PHOTO_FILE As Long = 6
Private Const COL_SIGNATURE_FILE As Long = 7
Private Const COL_SIGNATURE_AUTHORIZED As Long = 8
Private Const COL_REPORT_STATUS As Long = 9
Private Const COL_OUTPUT_NAME As Long = 10

Private Const STATUS_READY As String = "READY"
Private Const STATUS_HOLD As String = "HOLD"
Private Const VALUE_YES As String = "YES"
Private Const VALUE_NO As String = "NO"

Public Sub AuditIncidentReportSource()
    Dim wb As Workbook
    Dim dataWs As Worksheet
    Dim auditWs As Worksheet
    Dim lastCell As Range
    Dim lastRow As Long
    Dim rowNumber As Long
    Dim auditRow As Long
    Dim errorCount As Long
    Dim warningCount As Long
    Dim readyCount As Long
    Dim holdCount As Long
    Dim rowErrorStart As Long
    Dim incidentId As String
    Dim incidentDateText As String
    Dim siteName As String
    Dim reporterName As String
    Dim summaryText As String
    Dim photoFile As String
    Dim signatureFile As String
    Dim signatureAuthorized As String
    Dim reportStatus As String
    Dim outputName As String
    Dim photoPath As String
    Dim signaturePath As String
    Dim idRows As Object
    Dim outputRows As Object
    Dim auditName As String
    Dim errorNumber As Long
    Dim errorMessage As String

    On Error GoTo CleanFail

    Set wb = ThisWorkbook
    If Len(wb.Path) = 0 Then
        Err.Raise vbObjectError + 3100, , _
            "Save this workbook as .xlsm before running the audit."
    End If
    If wb.ReadOnly Then
        Err.Raise vbObjectError + 3101, , _
            "Open a writable copy of the audit workbook."
    End If
    If wb.ProtectStructure Then
        Err.Raise vbObjectError + 3102, , _
            "Unprotect the workbook structure before adding an audit sheet."
    End If

    Set dataWs = RequireWorksheet(wb, DATA_SHEET)
    ValidateHeaders dataWs

    Set lastCell = dataWs.Range("A:J").Find(What:="*", _
        After:=dataWs.Cells(1, 1), LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, _
        SearchDirection:=xlPrevious, MatchCase:=False)
    If lastCell Is Nothing Then
        Err.Raise vbObjectError + 3103, , _
            "The Incidents sheet is empty."
    End If
    If lastCell.Row < FIRST_DATA_ROW Then
        Err.Raise vbObjectError + 3103, , _
            "The Incidents sheet has no data rows."
    End If
    lastRow = lastCell.Row

    Set idRows = CreateObject("Scripting.Dictionary")
    idRows.CompareMode = vbBinaryCompare
    Set outputRows = CreateObject("Scripting.Dictionary")
    outputRows.CompareMode = vbTextCompare

    auditName = UniqueAuditSheetName(wb)
    Set auditWs = wb.Worksheets.Add(After:=wb.Worksheets(wb.Worksheets.Count))
    auditWs.Name = auditName
    WriteAuditHeaders auditWs
    auditRow = 2

    Application.ScreenUpdating = False

    For rowNumber = FIRST_DATA_ROW To lastRow
        rowErrorStart = errorCount
        If Application.CountA(dataWs.Range( _
            dataWs.Cells(rowNumber, COL_INCIDENT_ID), _
            dataWs.Cells(rowNumber, COL_OUTPUT_NAME))) = 0 Then
            WriteAuditRow auditWs, auditRow, rowNumber, "ROW", _
                "ERROR", "Blank row inside the data range.", _
                errorCount, warningCount
            GoTo NextRow
        End If

        incidentId = ReadRequiredText(dataWs.Cells(rowNumber, COL_INCIDENT_ID), _
            "IncidentID", rowNumber, auditWs, auditRow, errorCount, warningCount)
        If Not IsError(dataWs.Cells(rowNumber, COL_INCIDENT_ID).Value2) Then
            If VarType(dataWs.Cells(rowNumber, COL_INCIDENT_ID).Value2) <> vbString Then
                WriteAuditRow auditWs, auditRow, rowNumber, "IncidentID", _
                    "ERROR", _
                    "Store IncidentID as text so leading zeros and exact identity are preserved.", _
                    errorCount, warningCount
            End If
        End If
        incidentDateText = ReadRequiredDisplayText( _
            dataWs.Cells(rowNumber, COL_INCIDENT_DATE), _
            "IncidentDateDisplay", rowNumber, auditWs, auditRow, _
            errorCount, warningCount)
        siteName = ReadRequiredText(dataWs.Cells(rowNumber, COL_SITE_NAME), _
            "SiteName", rowNumber, auditWs, auditRow, errorCount, warningCount)
        reporterName = ReadRequiredText(dataWs.Cells(rowNumber, COL_REPORTER_NAME), _
            "ReporterName", rowNumber, auditWs, auditRow, errorCount, warningCount)
        summaryText = ReadRequiredText(dataWs.Cells(rowNumber, COL_SUMMARY), _
            "IncidentSummary", rowNumber, auditWs, auditRow, errorCount, warningCount)
        photoFile = ReadRequiredText(dataWs.Cells(rowNumber, COL_PHOTO_FILE), _
            "PhotoFile", rowNumber, auditWs, auditRow, errorCount, warningCount)
        signatureFile = ReadOptionalText( _
            dataWs.Cells(rowNumber, COL_SIGNATURE_FILE), _
            "SignatureFile", rowNumber, auditWs, auditRow, errorCount, warningCount)
        signatureAuthorized = ReadRequiredText( _
            dataWs.Cells(rowNumber, COL_SIGNATURE_AUTHORIZED), _
            "SignatureAuthorized", rowNumber, auditWs, auditRow, _
            errorCount, warningCount)
        reportStatus = ReadRequiredText( _
            dataWs.Cells(rowNumber, COL_REPORT_STATUS), _
            "ReportStatus", rowNumber, auditWs, auditRow, _
            errorCount, warningCount)
        outputName = ReadRequiredText(dataWs.Cells(rowNumber, COL_OUTPUT_NAME), _
            "OutputName", rowNumber, auditWs, auditRow, errorCount, warningCount)

        If Len(incidentId) > 0 Then
            ValidateIdentifier incidentId, "IncidentID", rowNumber, _
                auditWs, auditRow, errorCount, warningCount
            If idRows.Exists(incidentId) Then
                WriteAuditRow auditWs, auditRow, rowNumber, "IncidentID", _
                    "ERROR", "Duplicate exact IncidentID; first used in row " & _
                    idRows(incidentId) & ".", errorCount, warningCount
            Else
                idRows.Add incidentId, rowNumber
            End If
        End If

        If Len(outputName) > 0 Then
            ValidateFileStem outputName, rowNumber, auditWs, auditRow, _
                errorCount, warningCount
            If outputRows.Exists(outputName) Then
                WriteAuditRow auditWs, auditRow, rowNumber, "OutputName", _
                    "ERROR", "Duplicate output name; first used in row " & _
                    outputRows(outputName) & ".", errorCount, warningCount
            Else
                outputRows.Add outputName, rowNumber
            End If
        End If

        If reportStatus <> STATUS_READY And reportStatus <> STATUS_HOLD Then
            WriteAuditRow auditWs, auditRow, rowNumber, "ReportStatus", _
                "ERROR", "Use READY or HOLD exactly.", errorCount, warningCount
        ElseIf reportStatus = STATUS_READY Then
            readyCount = readyCount + 1
        Else
            holdCount = holdCount + 1
        End If

        If signatureAuthorized <> VALUE_YES And _
           signatureAuthorized <> VALUE_NO Then
            WriteAuditRow auditWs, auditRow, rowNumber, _
                "SignatureAuthorized", "ERROR", _
                "Use YES or NO exactly.", errorCount, warningCount
        ElseIf signatureAuthorized = VALUE_YES And Len(signatureFile) = 0 Then
            WriteAuditRow auditWs, auditRow, rowNumber, _
                "SignatureFile", "ERROR", _
                "An authorized signature requires a SignatureFile.", _
                errorCount, warningCount
        ElseIf signatureAuthorized = VALUE_NO And Len(signatureFile) > 0 Then
            WriteAuditRow auditWs, auditRow, rowNumber, _
                "SignatureFile", "ERROR", _
                "Remove the signature file or record separate approval before release.", _
                errorCount, warningCount
        End If

        If Len(photoFile) > 0 Then
            photoPath = ResolveAssetPath(wb.Path, photoFile, "PhotoFile", _
                rowNumber, auditWs, auditRow, errorCount, warningCount)
            If Len(photoPath) > 0 Then
                ValidateImageFile photoPath, "PhotoFile", rowNumber, _
                    auditWs, auditRow, errorCount, warningCount
            End If
        End If

        If signatureAuthorized = VALUE_YES And Len(signatureFile) > 0 Then
            signaturePath = ResolveAssetPath(wb.Path, signatureFile, _
                "SignatureFile", rowNumber, auditWs, auditRow, _
                errorCount, warningCount)
            If Len(signaturePath) > 0 Then
                ValidateImageFile signaturePath, "SignatureFile", rowNumber, _
                    auditWs, auditRow, errorCount, warningCount
            End If
        End If

        If Len(photoPath) > 0 And Len(signaturePath) > 0 Then
            If StrComp(photoPath, signaturePath, vbTextCompare) = 0 Then
                WriteAuditRow auditWs, auditRow, rowNumber, "ASSETS", _
                    "ERROR", "PhotoFile and SignatureFile resolve to the same file.", _
                    errorCount, warningCount
            End If
        End If

        If reportStatus = STATUS_HOLD Then
            WriteAuditRow auditWs, auditRow, rowNumber, "RELEASE", _
                "WARNING", "HOLD rows must not be generated or released.", _
                errorCount, warningCount
        ElseIf reportStatus = STATUS_READY Then
            If errorCount = rowErrorStart Then
                WriteAuditRow auditWs, auditRow, rowNumber, "RELEASE", _
                    "PASS", "READY row passed the checks recorded above.", _
                    errorCount, warningCount
            Else
                WriteAuditRow auditWs, auditRow, rowNumber, "RELEASE", _
                    "ERROR", _
                    "READY row has preflight errors and must not be generated.", _
                    errorCount, warningCount
            End If
        End If
NextRow:
        photoPath = vbNullString
        signaturePath = vbNullString
    Next rowNumber

    WriteSummary auditWs, readyCount, holdCount, errorCount, warningCount
    auditWs.Columns("A:F").AutoFit
    auditWs.Rows(1).Font.Bold = True
    wb.Save
    Application.ScreenUpdating = True

    MsgBox "Incident audit created: " & auditName & vbCrLf & _
           "READY rows: " & readyCount & vbCrLf & _
           "HOLD rows: " & holdCount & vbCrLf & _
           "Errors: " & errorCount & vbCrLf & _
           "Warnings: " & warningCount, _
           IIf(errorCount = 0, vbInformation, vbExclamation), _
           "Incident report source audit"
    Exit Sub

CleanFail:
    errorNumber = Err.Number
    errorMessage = Err.Description
    Application.ScreenUpdating = True
    MsgBox "Audit stopped." & vbCrLf & errorMessage, _
        vbCritical, "Incident report source audit"
    Err.Clear
End Sub

Private Function RequireWorksheet(ByVal wb As Workbook, _
                                  ByVal sheetName As String) As Worksheet
    On Error Resume Next
    Set RequireWorksheet = wb.Worksheets(sheetName)
    On Error GoTo 0
    If RequireWorksheet Is Nothing Then
        Err.Raise vbObjectError + 3110, , _
            "Required sheet is missing: " & sheetName
    End If
End Function

Private Sub ValidateHeaders(ByVal ws As Worksheet)
    Dim headers As Variant
    Dim columnNumber As Long
    Dim rawHeader As Variant
    headers = Array("IncidentID", "IncidentDateDisplay", "SiteName", _
        "ReporterName", "IncidentSummary", "PhotoFile", _
        "SignatureFile", "SignatureAuthorized", "ReportStatus", _
        "OutputName")
    For columnNumber = 1 To 10
        rawHeader = ws.Cells(1, columnNumber).Value2
        If IsError(rawHeader) Then
            Err.Raise vbObjectError + 3111, , _
                "Header " & ws.Cells(1, columnNumber).Address(False, False) & _
                " contains an Excel error."
        End If
        If StrComp(CStr(rawHeader), _
                   CStr(headers(columnNumber - 1)), vbBinaryCompare) <> 0 Then
            Err.Raise vbObjectError + 3111, , _
                "Header " & ws.Cells(1, columnNumber).Address(False, False) & _
                " must match exactly: " & headers(columnNumber - 1) & "."
        End If
    Next columnNumber
End Sub

Private Function ReadRequiredDisplayText(ByVal cell As Range, _
                                         ByVal fieldName As String, _
                                         ByVal rowNumber As Long, _
                                         ByVal auditWs As Worksheet, _
                                         ByRef auditRow As Long, _
                                         ByRef errorCount As Long, _
                                         ByRef warningCount As Long) As String
    Dim rawValue As Variant
    rawValue = cell.Value2
    If IsError(rawValue) Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Cell contains an Excel error.", errorCount, warningCount
        Exit Function
    End If
    If VarType(rawValue) <> vbString Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Store the document-ready date as text, not a numeric Excel date.", _
            errorCount, warningCount
        Exit Function
    End If
    ReadRequiredDisplayText = CStr(rawValue)
    ValidateTextValue ReadRequiredDisplayText, fieldName, rowNumber, _
        True, auditWs, auditRow, errorCount, warningCount
End Function

Private Function ReadRequiredText(ByVal cell As Range, _
                                  ByVal fieldName As String, _
                                  ByVal rowNumber As Long, _
                                  ByVal auditWs As Worksheet, _
                                  ByRef auditRow As Long, _
                                  ByRef errorCount As Long, _
                                  ByRef warningCount As Long) As String
    ReadRequiredText = ReadCellText(cell, fieldName, rowNumber, True, _
        auditWs, auditRow, errorCount, warningCount)
End Function

Private Function ReadOptionalText(ByVal cell As Range, _
                                  ByVal fieldName As String, _
                                  ByVal rowNumber As Long, _
                                  ByVal auditWs As Worksheet, _
                                  ByRef auditRow As Long, _
                                  ByRef errorCount As Long, _
                                  ByRef warningCount As Long) As String
    ReadOptionalText = ReadCellText(cell, fieldName, rowNumber, False, _
        auditWs, auditRow, errorCount, warningCount)
End Function

Private Function ReadCellText(ByVal cell As Range, _
                              ByVal fieldName As String, _
                              ByVal rowNumber As Long, _
                              ByVal required As Boolean, _
                              ByVal auditWs As Worksheet, _
                              ByRef auditRow As Long, _
                              ByRef errorCount As Long, _
                              ByRef warningCount As Long) As String
    Dim rawValue As Variant
    rawValue = cell.Value2
    If IsError(rawValue) Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Cell contains an Excel error.", errorCount, warningCount
        Exit Function
    End If
    ReadCellText = CStr(rawValue)
    ValidateTextValue ReadCellText, fieldName, rowNumber, required, _
        auditWs, auditRow, errorCount, warningCount
End Function

Private Sub ValidateTextValue(ByVal valueText As String, _
                              ByVal fieldName As String, _
                              ByVal rowNumber As Long, _
                              ByVal required As Boolean, _
                              ByVal auditWs As Worksheet, _
                              ByRef auditRow As Long, _
                              ByRef errorCount As Long, _
                              ByRef warningCount As Long)
    If required And Len(valueText) = 0 Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Required value is blank.", errorCount, warningCount
        Exit Sub
    End If
    If StrComp(valueText, Trim$(valueText), vbBinaryCompare) <> 0 Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Leading or trailing spaces are not allowed.", _
            errorCount, warningCount
    End If
    If InStr(valueText, vbCr) > 0 Or InStr(valueText, vbLf) > 0 Or _
       InStr(valueText, vbTab) > 0 Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Tabs and line breaks are not allowed in this source field.", _
            errorCount, warningCount
    End If
End Sub

Private Sub ValidateIdentifier(ByVal valueText As String, _
                               ByVal fieldName As String, _
                               ByVal rowNumber As Long, _
                               ByVal auditWs As Worksheet, _
                               ByRef auditRow As Long, _
                               ByRef errorCount As Long, _
                               ByRef warningCount As Long)
    Dim i As Long
    Dim character As String
    For i = 1 To Len(valueText)
        character = Mid$(valueText, i, 1)
        If Not (character Like "[A-Za-z0-9_-]") Then
            WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
                "Use only letters, digits, underscore, and hyphen.", _
                errorCount, warningCount
            Exit Sub
        End If
    Next i
End Sub

Private Sub ValidateFileStem(ByVal fileStem As String, _
                             ByVal rowNumber As Long, _
                             ByVal auditWs As Worksheet, _
                             ByRef auditRow As Long, _
                             ByRef errorCount As Long, _
                             ByRef warningCount As Long)
    Dim forbidden As Variant
    Dim item As Variant
    Dim baseName As String
    Dim upperBase As String
    forbidden = Array("\", "/", ":", "*", "?", """", "<", ">", "|")
    If Len(fileStem) > 120 Then
        WriteAuditRow auditWs, auditRow, rowNumber, "OutputName", "ERROR", _
            "Use 120 characters or fewer before the extension.", _
            errorCount, warningCount
    End If
    If Right$(fileStem, 1) = "." Or Right$(fileStem, 1) = " " Then
        WriteAuditRow auditWs, auditRow, rowNumber, "OutputName", "ERROR", _
            "A Windows filename cannot end with a dot or space.", _
            errorCount, warningCount
    End If
    If LCase$(Right$(fileStem, 5)) = ".docx" Or _
       LCase$(Right$(fileStem, 4)) = ".pdf" Then
        WriteAuditRow auditWs, auditRow, rowNumber, "OutputName", "ERROR", _
            "Store the output stem without .docx or .pdf.", _
            errorCount, warningCount
    End If
    For Each item In forbidden
        If InStr(1, fileStem, CStr(item), vbBinaryCompare) > 0 Then
            WriteAuditRow auditWs, auditRow, rowNumber, "OutputName", "ERROR", _
                "Filename contains a forbidden character: " & item, _
                errorCount, warningCount
        End If
    Next item
    baseName = Trim$(fileStem)
    If InStr(1, baseName, ".", vbBinaryCompare) > 0 Then
        baseName = Left$(baseName, InStr(1, baseName, ".", vbBinaryCompare) - 1)
    End If
    upperBase = UCase$(baseName)
    If IsReservedWindowsName(upperBase) Then
        WriteAuditRow auditWs, auditRow, rowNumber, "OutputName", "ERROR", _
            "Filename starts with a reserved Windows device name.", _
            errorCount, warningCount
    End If
End Sub

Private Function IsReservedWindowsName(ByVal upperBase As String) As Boolean
    Dim finalCharacter As String
    Select Case upperBase
        Case "CON", "PRN", "AUX", "NUL", "CLOCK$"
            IsReservedWindowsName = True
            Exit Function
    End Select
    If Left$(upperBase, 3) = "COM" Or Left$(upperBase, 3) = "LPT" Then
        If Len(upperBase) = 4 And Mid$(upperBase, 4, 1) Like "[1-9]" Then
            IsReservedWindowsName = True
            Exit Function
        End If
        If Len(upperBase) = 4 Then
            finalCharacter = Mid$(upperBase, 4, 1)
            If finalCharacter = ChrW$(&HB9) Or _
               finalCharacter = ChrW$(&HB2) Or _
               finalCharacter = ChrW$(&HB3) Then
                IsReservedWindowsName = True
            End If
        End If
    End If
End Function

Private Sub ValidateAssetFileName(ByVal fileName As String, _
                                  ByVal fieldName As String, _
                                  ByVal rowNumber As Long, _
                                  ByVal auditWs As Worksheet, _
                                  ByRef auditRow As Long, _
                                  ByRef errorCount As Long, _
                                  ByRef warningCount As Long)
    Dim forbidden As Variant
    Dim item As Variant
    Dim character As String
    Dim characterCode As Long
    Dim position As Long
    Dim baseName As String

    forbidden = Array("\", "/", ":", "*", "?", """", "<", ">", "|")
    If StrComp(fileName, Trim$(fileName), vbBinaryCompare) <> 0 Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Leading or trailing spaces are not allowed in an asset filename.", _
            errorCount, warningCount
    End If
    If Right$(fileName, 1) = "." Or Right$(fileName, 1) = " " Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "An asset filename cannot end with a dot or space.", _
            errorCount, warningCount
    End If
    For Each item In forbidden
        If InStr(1, fileName, CStr(item), vbBinaryCompare) > 0 Then
            WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
                "Asset filename contains a forbidden character: " & item, _
                errorCount, warningCount
        End If
    Next item
    For position = 1 To Len(fileName)
        character = Mid$(fileName, position, 1)
        characterCode = AscW(character)
        If characterCode >= 0 And characterCode < 32 Then
            WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
                "Asset filename contains a Windows control character.", _
                errorCount, warningCount
            Exit For
        End If
    Next position
    baseName = fileName
    If InStr(1, baseName, ".", vbBinaryCompare) > 0 Then
        baseName = Left$(baseName, InStr(1, baseName, ".", vbBinaryCompare) - 1)
    End If
    If Len(baseName) = 0 Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Asset filename must include a name before the extension.", _
            errorCount, warningCount
    ElseIf IsReservedWindowsName(UCase$(baseName)) Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Asset filename starts with a reserved Windows device name.", _
            errorCount, warningCount
    End If
End Sub

Private Function ResolveAssetPath(ByVal workbookPath As String, _
                                  ByVal relativeFile As String, _
                                  ByVal fieldName As String, _
                                  ByVal rowNumber As Long, _
                                  ByVal auditWs As Worksheet, _
                                  ByRef auditRow As Long, _
                                  ByRef errorCount As Long, _
                                  ByRef warningCount As Long) As String
    Dim errorsBefore As Long
    errorsBefore = errorCount
    ValidateAssetFileName relativeFile, fieldName, rowNumber, _
        auditWs, auditRow, errorCount, warningCount
    If errorCount > errorsBefore Then Exit Function
    If InStr(relativeFile, ":") > 0 Or Left$(relativeFile, 1) = "\" Or _
       Left$(relativeFile, 1) = "/" Or InStr(relativeFile, "..") > 0 Or _
       InStr(relativeFile, "\") > 0 Or InStr(relativeFile, "/") > 0 Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Use a filename only; files must be inside IncidentAssets.", _
            errorCount, warningCount
        Exit Function
    End If
    ResolveAssetPath = workbookPath & ASSET_FOLDER & "\" & relativeFile
End Function

Private Sub ValidateImageFile(ByVal filePath As String, _
                              ByVal fieldName As String, _
                              ByVal rowNumber As Long, _
                              ByVal auditWs As Worksheet, _
                              ByRef auditRow As Long, _
                              ByRef errorCount As Long, _
                              ByRef warningCount As Long)
    Dim extension As String
    Dim dotPosition As Long
    dotPosition = InStrRev(filePath, ".")
    If dotPosition = 0 Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Image filename has no extension.", errorCount, warningCount
        Exit Sub
    End If
    extension = LCase$(Mid$(filePath, dotPosition + 1))
    If extension <> "jpg" And extension <> "jpeg" And extension <> "png" Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "Use JPG, JPEG, or PNG only.", errorCount, warningCount
        Exit Sub
    End If
    If Len(Dir$(filePath, vbNormal Or vbReadOnly Or vbHidden Or vbSystem)) = 0 Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "File is missing: " & filePath, errorCount, warningCount
        Exit Sub
    End If
    If FileLen(filePath) = 0 Then
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "ERROR", _
            "File exists but is empty: " & filePath, errorCount, warningCount
    Else
        WriteAuditRow auditWs, auditRow, rowNumber, fieldName, "PASS", _
            "File exists and is non-empty.", errorCount, warningCount
    End If
End Sub

Private Function UniqueAuditSheetName(ByVal wb As Workbook) As String
    Dim baseName As String
    Dim candidate As String
    Dim counter As Long
    baseName = AUDIT_PREFIX & Format$(Now, "yyyymmdd_hhnnss")
    candidate = Left$(baseName, 31)
    counter = 1
    Do While WorksheetExists(wb, candidate)
        counter = counter + 1
        candidate = Left$(baseName, 27) & "_" & counter
    Loop
    UniqueAuditSheetName = candidate
End Function

Private Function WorksheetExists(ByVal wb As Workbook, _
                                 ByVal sheetName As String) As Boolean
    Dim ws As Worksheet
    On Error Resume Next
    Set ws = wb.Worksheets(sheetName)
    WorksheetExists = Not ws Is Nothing
    On Error GoTo 0
End Function

Private Sub WriteAuditHeaders(ByVal ws As Worksheet)
    ws.Cells(1, 1).Value = "SourceRow"
    ws.Cells(1, 2).Value = "IncidentID"
    ws.Cells(1, 3).Value = "Check"
    ws.Cells(1, 4).Value = "Result"
    ws.Cells(1, 5).Value = "Details"
    ws.Cells(1, 6).Value = "CheckedAt"
End Sub

Private Sub WriteAuditRow(ByVal auditWs As Worksheet, _
                          ByRef auditRow As Long, _
                          ByVal sourceRow As Long, _
                          ByVal checkName As String, _
                          ByVal resultText As String, _
                          ByVal details As String, _
                          ByRef errorCount As Long, _
                          ByRef warningCount As Long)
    auditWs.Cells(auditRow, 1).Value = sourceRow
    If sourceRow >= FIRST_DATA_ROW Then
        auditWs.Cells(auditRow, 2).Value = _
            ThisWorkbook.Worksheets(DATA_SHEET).Cells( _
                sourceRow, COL_INCIDENT_ID).Value2
    End If
    auditWs.Cells(auditRow, 3).Value = checkName
    auditWs.Cells(auditRow, 4).Value = resultText
    auditWs.Cells(auditRow, 5).Value = details
    auditWs.Cells(auditRow, 6).Value = Now
    If resultText = "ERROR" Then errorCount = errorCount + 1
    If resultText = "WARNING" Then warningCount = warningCount + 1
    auditRow = auditRow + 1
End Sub

Private Sub WriteSummary(ByVal ws As Worksheet, _
                         ByVal readyCount As Long, _
                         ByVal holdCount As Long, _
                         ByVal errorCount As Long, _
                         ByVal warningCount As Long)
    ws.Range("H1").Value = "SUMMARY"
    ws.Range("H2").Value = "READY rows"
    ws.Range("I2").Value = readyCount
    ws.Range("H3").Value = "HOLD rows"
    ws.Range("I3").Value = holdCount
    ws.Range("H4").Value = "Errors"
    ws.Range("I4").Value = errorCount
    ws.Range("H5").Value = "Warnings"
    ws.Range("I5").Value = warningCount
    ws.Range("H7").Value = "Scope"
    ws.Range("I7").Value = _
        "Preflight only; no Word or PDF files were generated."
    ws.Columns("H:I").AutoFit
End Sub

Use the audit as a release gate, not a compliance certificate

ERROR

Correct the exact row and field. Do not generate that row merely because the missing value can be guessed.

WARNING

HOLD rows remain excluded. Resolve the underlying review decision before changing the status.

PASS

The declared preflight check passed. It does not validate the truth of the incident account or authorization record.

Duplicate ID

Determine whether the record is a correction, a second event, or an accidental duplicate. Do not silently renumber it.

Missing asset

Restore the approved file or put the row on HOLD. Do not substitute a similarly named image without review.

Clean audit

Proceed to a small generation pilot and inspect both DOCX and PDF. Static checks cannot prove final layout.

Run a six-record incident-report pilot

1. Typical READY row

Verify every text destination, filename, evidence photo, page break, and final output format.

2. Long summary

Use the longest approved narrative and confirm that tables, headings, and signature area remain stable.

3. Portrait photo

Confirm aspect ratio, maximum size, caption placement, and PDF export.

4. Landscape photo

Confirm that a wide image does not push fixed report content beyond the intended page layout.

5. Authorized signature

Verify the approved signer image and the separate authorization record for this workflow.

6. HOLD row

Confirm the production step excludes it and reports the exclusion clearly.

Final human review

Check facts, evidence, redactions, authorization, document identity, and both output formats before distribution. Automation standardizes assembly; it does not make the incident decision.

Generate standard incident reports with Factory

DocxForge Pro Factory fits many independent incident rows, one approved Word template, and one separate report per selected row.

Review Excel rows

Confirm the exact field mapping, READY rows, document-ready values, asset filenames, and unique output names.

Review the template

Confirm the approved standard report, text destinations, evidence photo destination, signature destination, and output settings.

Generate a pilot first

Start with representative rows and inspect DOCX/PDF before increasing the batch.

Where it does not fit

Use Contractor when one incident case must create several different documents from different Word templates.

DocxForge Pro Factory Excel data for standard incident reports
Review incident rows and document-ready field values.
DocxForge Pro Factory document settings for one incident report template
Confirm one approved report template and the output settings.
Turn approved incident rows into consistent Word and PDF reportsTry DocxForge Pro for 7 days free. Then $38 every 3 months • 14-day refund after purchase.
Factory workflowEvidence photosLocal processingDOCX + PDF
Start Free 7-Day Trial

Frequently asked questions

Is an embedded signature image a digital signature?

No. A pasted signature image is not a cryptographic digital signature, proof of identity, or proof that a signer authorized this specific report. Approve its use separately and keep the authorization record outside the image file.

Should every incident row contain a signature?

No. Use an explicit SignatureAuthorized value. When it is NO, leave SignatureFile blank and route the report through the documented review or approval process instead of inserting an image automatically.

Why store IncidentDateDisplay as text?

Excel stores dates as numbers. A document-ready text field preserves the approved visible date and avoids sending a serial number or locale-dependent value into Word.

Can one Excel row create several different incident documents?

Not in the Factory model described here. Factory uses many independent rows and one standard Word template. If one incident case must produce several different documents from different templates, use a Contractor-style case workflow.

Does the VBA helper generate Word or PDF reports?

No. It creates a timestamped Excel audit sheet and checks source data, image files, authorization flags, identifiers, and output names. Generation remains a separate controlled step.

Does a clean audit prove the incident report is complete or compliant?

No. It proves only that the declared source contract passed these static checks. A responsible reviewer must still verify facts, evidence, authorization, document layout, and the final DOCX/PDF before release.

Standardize repeat incident-report assembly without moving the workflow to the cloudRun DocxForge Pro locally. 7 days free, then $38 every 3 months • 14-day refund after purchase.
One incident per rowOne approved templateControlled imagesReviewable output
Start Free 7-Day Trial