# PDF Modification Module (pdfMod.bas) ## Overview This VBA module provides functionality for manipulating PDF files directly within Excel. It includes capabilities for merging PDFs, extracting pages, and handling PDF-related operations. ## Functions and Subroutines ### MergePDFs Combines multiple PDF files into a single output PDF. Public Sub MergePDFs(inputFiles As Collection, outputPath As String) #### Parameters - `inputFiles`: Collection of file paths to input PDFs - `outputPath`: Destination path for merged PDF file ### ExtractPages Extracts specific pages from a PDF file. Public Sub ExtractPages(inputPath As String, outputPath As String, startPage As Long, endPage As Long) #### Parameters - `inputPath`: Source PDF file path - `outputPath`: Destination path for extracted pages - `startPage`: First page to extract - `endPage`: Last page to extract ### AddWatermark Adds a watermark to each page of a PDF. Public Sub AddWatermark(inputPath As String, outputPath As String, watermarkText As String) #### Parameters - `inputPath`: Source PDF file path - `outputPath`: Destination path for watermarked PDF - `watermarkText`: Text to use as watermark ## Dependencies - Requires Adobe Acrobat installation - Uses Microsoft Scripting Runtime for file system operations ## Error Handling - Includes comprehensive error handling for file operations - Validates PDF file existence and accessibility - Checks for valid page ranges in extraction operations ## Usage Examples ' Merge PDFs Example Dim pdfs As New Collection pdfs.Add "C:\path\to\first.pdf" pdfs.Add "C:\path\to\second.pdf" MergePDFs pdfs, "C:\path\to\output.pdf" ' Extract Pages Example ExtractPages "C:\input.pdf", "C:\output.pdf", 1, 5 ' Add Watermark Example AddWatermark "C:\input.pdf", "C:\output.pdf", "CONFIDENTIAL"