SYSTEMS / FINANCIAL & LEGAL OPERATIONS
Microsoft 365 Document Automation
Generate the documents. Keep the logic.
We built a system for generating corporate reports and contracts in bulk, using the Excel and Word templates the business already relied on.
Microservices connect Microsoft Graph, OneDrive for Business, Python and Open XML to populate documents and deliver them to the right client folders.
Concept illustration of the document workflow.
USE CASE
Corporate reporting & contracts
INTEGRATION
Microsoft 365 & OneDrive for Business
OUR CONTRIBUTION
Architecture, backend development & API integration
01 / THE OPERATIONAL CHALLENGE
The template was already part of the system.
Financial workbooks contained formulas, reporting views and VBA. Legal documents carried corporate styles, carefully structured text and review macros. Rebuilding those files from scratch risked losing more than their appearance.
The task was to automate repeated preparation and delivery while keeping the business logic inside the existing documents.
We developed the integration around a simple principle: copy the master template, change the intended inputs, and preserve the surrounding structure.
02 / THE WORKFLOW
From month-end close to client delivery.
The architecture separates file orchestration from document processing. Microsoft Graph handles the OneDrive workflow; specialised workers populate each document type.
Month-end close event
Starts the reporting and document-generation run.
Microsoft Graph → OneDrive working folder
OAuth 2.0 with delegated permissions. Copy the master templates into a temporary working folder.
EXCEL PATH
Populate workbook inputs
Bulk writes to the hidden Raw_Data sheet in the .xlsm template. Targeted Graph range updates form a separate path for compatible workbooks.
WORD PATH
Populate Content Controls
Update the identified fields inside the .docm Open XML package while retaining its document structure and macro parts.
Client folders → Sharing links → Email
Move the generated files to their destination folders, create sharing links and send the delivery email.
Simplified architecture of the implemented workflow.
03 / EXCEL AUTOMATION
New data in. Existing calculations retained.
Bulk processing with Python
We used openpyxl with keep_vba=True for the macro-enabled workbook path. The worker writes business data only to the hidden Raw_Data sheet, leaving the presentation sheets outside its intended write area.
This keeps data injection separate from the formulas and report layout maintained by the business. Formula calculation and any pivot or external-data refresh remain Excel operations, governed by the workbook’s configuration.
WORKBOOK / .XLSM
Raw_Data
Updated by the automation worker
Presentation sheets
Existing formulas · reporting views · formatting
VBA project
Retained in the macro-enabled package
Targeted updates with Microsoft Graph
For compatible workbooks, we also used the workbook worksheet and range endpoints to update selected inputs in the cloud, without downloading the file.
A range update can send values without rewriting unrelated formatting properties. This is a separate route from .xlsm file processing: storing a document through Graph does not imply that its contents are supported by the Excel workbook API.
Template compatibility matters: keep_vba=True is not a guarantee that every Excel feature survives an open/save cycle. Supported objects, recalculation and refresh behaviour need to be checked against the actual templates.
04 / WORD AUTOMATION
Change the content, preserve the document.
Business users placed Content Controls in the Word templates wherever dynamic text belonged. We built an Open XML injection engine to locate those controls by ID and update their contents.
The approach works within the existing .docm package, retaining the relevant paragraph and run properties, corporate styles and VBA components instead of reconstructing the document as plain text.
Executive summaries and contracts therefore start from the same maintained templates used by the business.
DOCUMENT / .DOCM
Template-defined fields
Illustrative field mapping
Client name → Content Control
Reporting period → Content Control
Summary text → Content Control
Surrounding structure retained: styles, paragraphs, page layout and macro package.
05 / FILES & DELIVERY
One connected document lifecycle.
01 / COPY
Start from the master
Graph copies the existing file into a working folder. The original template stays available for the next run.
02 / POPULATE
Write to defined inputs
Excel and Word workers update their designated data areas and fields, using the appropriate processing path.
03 / DELIVER
Put the files in place
The system moves the outputs into each client’s OneDrive folder, creates sharing links and emails them automatically.
Access remains subject to Microsoft 365 tenant policies and the delegated user’s permissions. Copying a file creates a new drive item; sharing and destination permissions are separate from preserving its document contents.
06 / WHAT THE PROJECT DELIVERED
Automation around the tools teams already use.
Reusable business templates
The established Excel and Word documents remain the starting point for recurring reporting and contract generation.
A repeatable batch workflow
Data population and file distribution become connected steps instead of a sequence of manual copy, edit and email tasks.
Direct implementation
We designed the microservices architecture and implemented the document workers, Microsoft Graph integration and delivery flow.
Technology
Microsoft Graph · OneDrive for Business · OAuth 2.0 · Python · openpyxl · Open XML · Excel .xlsm · Word .docm
Related engineering
LET’S TALK ABOUT YOUR WORKFLOW
What should your documents do automatically?
We can help at any stage: a focused integration review, a specialised document-processing component, or the architecture and development of the complete system.
Technical notes & references
Implementation details above describe this project. The links below document the underlying platform behaviours and compatibility boundaries.