docs: update documentation for Access file support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-05-11 09:41:18 +08:00
parent df81562dd9
commit ee1120c247
2 changed files with 21 additions and 14 deletions

1
.gitignore vendored
View File

@@ -15,4 +15,5 @@ tmpclaude-*
*.png
data/
Excel/
Access/
VBA/

View File

@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview
**Auto_BOM** is a VBA code extraction and management toolkit for Excel-based Bill of Materials (BOM) processing. The project provides Python tools to extract VBA code from `.xlsm` files, manage it externally, and import it back into Excel.
**Auto_BOM** is a VBA code extraction and management toolkit for Excel-based Bill of Materials (BOM) processing. The project provides Python tools to extract VBA code from `.xlsm` (Excel) and `.accdb` (Access) files, manage it externally, and import it back.
The VBA code implements a hierarchical BOM management system with:
- **clsBOMManager**: Main class managing BOM data structure and category relationships
@@ -16,14 +16,15 @@ The VBA code implements a hierarchical BOM management system with:
```
Auto_BOM/
├── Excel/ # Source Excel files (.xlsm) - gitignored
├── Access/ # Source Access files (.accdb) - gitignored
├── VBA/ # Extracted VBA code - gitignored
│ ├── Modules/ # Standard modules (.bas)
│ ├── ClassModules/ # Class modules (.cls)
│ ├── DocumentModules/# Sheet/workbook modules (.cls)
│ ├── Forms/ # User forms
│ └── vba_metadata.json # Module metadata for import
├── extract_vba.py # Extract VBA from Excel files
├── import_vba.py # Import VBA back to Excel files
├── extract_vba.py # Extract VBA from Excel/Access files
├── import_vba.py # Import VBA back to Excel/Access files
├── main.py # Empty placeholder
└── requirements.txt # Python dependencies
```
@@ -40,8 +41,8 @@ pip install -r requirements.txt
```
**Dependencies:**
- `pywin32>=306` - Windows COM interface for Excel automation (Windows only)
- `oletools>=0.60` - Alternative VBA extraction without Excel dependency
- `pywin32>=306` - Windows COM interface for Excel/Access automation (Windows only)
- `oletools>=0.60` - Alternative VBA extraction without Excel dependency (Excel only)
## Common Commands
@@ -51,20 +52,24 @@ pip install -r requirements.txt
python extract_vba.py
```
Two extraction methods available:
**Excel (.xlsm)** - Two extraction methods available:
1. **COM Interface** (recommended) - Requires Microsoft Excel, more reliable
2. **olevba Library** - No Excel required, uses oletools
For COM method, ensure Excel trusts VBA access:
**Access (.accdb)** - Only COM Interface supported (requires Microsoft Access)
For COM method, ensure the application trusts VBA access:
- Excel > Options > Trust Center > Trust Center Settings
- Check "Trust access to the VBA project object model"
### Import VBA Code
```bash
# Import from VBA/ directory back to Excel
python import_vba.py VBA/vba_metadata.json
# Import from VBA/ directory back to Excel or Access
python import_vba.py
```
Set `TARGET_FILE` in `.env` to the target `.xlsm` or `.accdb` file path.
## VBA Code Architecture
### BOM Data Model
@@ -98,12 +103,12 @@ The VBA system implements a hierarchical category-based material management:
- Cleans `Attribute` statements from exported code for readability
- Automatically categorizes modules by type (Standard/Class/Document/Form)
- Generates `vba_metadata.json` tracking source file, module names, types, and file mappings
- Module type detection based on naming conventions (mod_=Standard, cls=Class, sheet=Document)
- Auto-detects file type by extension (.xlsm → Excel, .accdb → Access)
### VBA Import (import_vba.py)
- Uses Windows COM to interact with Excel
- Uses Windows COM to interact with Excel or Access
- **Critical fix for ClassModules**: Reconstructs `VERSION 1.0 CLASS` header before import
- **Encoding handling**: Uses GB18030 for temp files to prevent Chinese character corruption
- Path recognition logic handles relative/absolute paths in metadata
@@ -125,15 +130,16 @@ The `.vscode/settings.json` associates `.cls` files with Visual Basic syntax hig
## Platform Requirements
- **Windows required** for import functionality (COM interface)
- **Microsoft Excel** required for COM-based extraction/import
- Cross-platform extraction possible with oletools (no Excel needed)
- **Microsoft Excel** required for Excel COM-based extraction/import
- **Microsoft Access** required for Access COM-based extraction/import
- Cross-platform extraction possible with oletools (Excel only, no Office needed)
## Git Workflow
The `.gitignore` excludes:
- Virtual environment (`.venv/`)
- Build artifacts (`build/`, `dist/`)
- Project data (`Excel/`, `VBA/`)
- Project data (`Excel/`, `Access/`, `VBA/`)
- Claude temporary files (`.claude/`, `tmpclaude-*`)
Only commit code changes, not extracted VBA or Excel files.