Write module
xlide_write_moduleWrite or replace a VBA module in Excel, Word, PowerPoint, or Access files. Uses a content token to prevent overwriting changed code, then returns a diff of the saved result.
Instructions
The canonical way to change VBA. Writes a module's source into the Office file and saves it. It replaces the module's whole source, so send all of it; send the body only, because the attribute header is managed for you. A module that does not exist is created: standard by default, or a class with kind='class'. Pass expected_content_token from your read and the write is refused if the module changed since. The result carries a diff of what the file now holds, read back after saving, which is what to show the user when they ask what changed. After writing, call xlide_analyze and treat any error as a build failure. Ask the user first when the project is protected or signed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | Kind for a module being created: 'standard' or 'class'. | standard |
| source | Yes | The module's complete VBA source. | |
| file_path | Yes | Absolute path to the Office file. | |
| module_name | Yes | Module to write, or to create. | |
| include_diff | No | Include a unified diff of what changed. Off in a loop that writes many modules and reads none of them back. | |
| allow_protected | No | Write to a password-protected project. Ask the user first. | |
| expected_content_token | No | The content_token from your read. Leave empty only when creating a module. | |
| allow_invalidate_signature | No | Write to a digitally signed project, dropping the signature. Ask the user first. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||