A Microsoft Excel VBA automation tool that generates a ready-to-deliver Microsoft Word quotation from information entered in an Excel workbook.
The project is designed for professional-service quotations, including expert-witness / forensic-engineering work, but the workbook can be adapted to other quotation workflows.
The Excel workbook contains VBA macros that automate the preparation of a Word document:
- Reads quotation data from Excel cells.
- Calculates the subtotal, 16% VAT, and total amount.
- Calculates the total number of working hours from the activity table.
- Converts monetary amounts to Spanish words.
- Builds a payment statement using the calculated amounts.
- Creates a new Microsoft Word document.
- Copies selected text blocks from Excel to Word.
- Copies quotation tables from Excel to Word.
- Adds spacing between the copied sections.
- Adjusts table widths to fit the document.
- Applies paragraph alignment and bold formatting.
- Sets Spanish as the Word proofing language.
- Saves the generated document as a
.docxfile. - Closes Word after saving.
.
├── PeritoQuoteGenerator.xlsm
├── README.md
├── LICENSE
├── .gitignore
├── GITHUB_DESCRIPTION.txt
├── GITHUB_TOPICS.txt
└── docs/
└── VBA_OVERVIEW.md
- Microsoft Excel for Windows with VBA support.
- Microsoft Word for Windows.
- Macros must be enabled in Excel.
- The VBA code uses Word automation through
CreateObject, so a local Microsoft Word installation is required. - The workbook was created for a Spanish-language quotation workflow. The generated payment text and number-to-words function are in Spanish.
- Download
PeritoQuoteGenerator.xlsm. - Open it in Microsoft Excel for Windows.
- Enable macros when prompted.
- Enter or replace the quotation information in the worksheet.
- Review the hourly rate, activities, hours, and calculated amounts.
- Set the destination folder and quotation/document name according to the VBA configuration.
- Run the
PasteTableInWordmacro. - Review the generated Word document before delivery.
The sample workbook uses the following main areas:
| Area | Purpose |
|---|---|
E3 |
Quotation/document name |
E4 |
Destination folder |
E5:E8 |
Header and case information copied to Word |
E9:G15 |
Main quotation table |
J1:L3 |
Amount/payment summary |
E2 |
Hourly professional fee |
F11:F17 |
Hours by activity |
G11:G17 |
Amount by activity |
F18:G18 |
Total hours and subtotal |
L1 |
Subtotal |
L2 |
16% VAT |
L3 |
Total amount |
These ranges are part of the current VBA implementation and can be changed in the code when adapting the workbook.
The workbook includes a VBA function named NumLetras. It converts numeric amounts into Spanish written amounts and handles the decimal/cents portion using the 00/100 format.
For example, an amount such as:
30,209.08
can be incorporated into a Spanish payment statement as a written amount.
The wording is intended for quotation documents and should be reviewed before using the output in a legally binding or financial document.
The main areas to customize are:
- Excel cell locations.
- Word document formatting.
- Output folder.
- Output file naming.
- Number-to-words wording.
- VAT rate.
- Currency wording.
- Quotation table ranges.
- Case-specific text.
- Professional fee calculation.
The VBA project currently contains the main Word-generation routine PasteTableInWord and the number-to-words functionality.
See docs/VBA_OVERVIEW.md for a higher-level description of the automation.
The GitHub version of the workbook is a sanitized sample. Personal names, banking information, case information, and local Windows paths have been replaced with placeholders.
Do not publish a production workbook containing:
- Bank account numbers.
- CLABE numbers.
- Personal addresses or telephone numbers.
- Client information.
- Confidential case information.
- Private file-system paths.
- Other personal or confidential data.
Always review the workbook before making a repository public.
This project is released under the MIT License. See LICENSE.
This project is an Excel/Word automation example. It does not provide legal advice, accounting advice, or professional fee guidance. Users are responsible for reviewing the generated documents, calculations, legal references, and applicable tax or professional-fee requirements before delivery.