docs: update documentation for Access file support
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,4 +15,5 @@ tmpclaude-*
|
|||||||
*.png
|
*.png
|
||||||
data/
|
data/
|
||||||
Excel/
|
Excel/
|
||||||
|
Access/
|
||||||
VBA/
|
VBA/
|
||||||
34
CLAUDE.md
34
CLAUDE.md
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||||||
|
|
||||||
## Project Overview
|
## 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:
|
The VBA code implements a hierarchical BOM management system with:
|
||||||
- **clsBOMManager**: Main class managing BOM data structure and category relationships
|
- **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/
|
Auto_BOM/
|
||||||
├── Excel/ # Source Excel files (.xlsm) - gitignored
|
├── Excel/ # Source Excel files (.xlsm) - gitignored
|
||||||
|
├── Access/ # Source Access files (.accdb) - gitignored
|
||||||
├── VBA/ # Extracted VBA code - gitignored
|
├── VBA/ # Extracted VBA code - gitignored
|
||||||
│ ├── Modules/ # Standard modules (.bas)
|
│ ├── Modules/ # Standard modules (.bas)
|
||||||
│ ├── ClassModules/ # Class modules (.cls)
|
│ ├── ClassModules/ # Class modules (.cls)
|
||||||
│ ├── DocumentModules/# Sheet/workbook modules (.cls)
|
│ ├── DocumentModules/# Sheet/workbook modules (.cls)
|
||||||
│ ├── Forms/ # User forms
|
│ ├── Forms/ # User forms
|
||||||
│ └── vba_metadata.json # Module metadata for import
|
│ └── vba_metadata.json # Module metadata for import
|
||||||
├── extract_vba.py # Extract VBA from Excel files
|
├── extract_vba.py # Extract VBA from Excel/Access files
|
||||||
├── import_vba.py # Import VBA back to Excel files
|
├── import_vba.py # Import VBA back to Excel/Access files
|
||||||
├── main.py # Empty placeholder
|
├── main.py # Empty placeholder
|
||||||
└── requirements.txt # Python dependencies
|
└── requirements.txt # Python dependencies
|
||||||
```
|
```
|
||||||
@@ -40,8 +41,8 @@ pip install -r requirements.txt
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Dependencies:**
|
**Dependencies:**
|
||||||
- `pywin32>=306` - Windows COM interface for Excel automation (Windows only)
|
- `pywin32>=306` - Windows COM interface for Excel/Access automation (Windows only)
|
||||||
- `oletools>=0.60` - Alternative VBA extraction without Excel dependency
|
- `oletools>=0.60` - Alternative VBA extraction without Excel dependency (Excel only)
|
||||||
|
|
||||||
## Common Commands
|
## Common Commands
|
||||||
|
|
||||||
@@ -51,20 +52,24 @@ pip install -r requirements.txt
|
|||||||
python extract_vba.py
|
python extract_vba.py
|
||||||
```
|
```
|
||||||
|
|
||||||
Two extraction methods available:
|
**Excel (.xlsm)** - Two extraction methods available:
|
||||||
1. **COM Interface** (recommended) - Requires Microsoft Excel, more reliable
|
1. **COM Interface** (recommended) - Requires Microsoft Excel, more reliable
|
||||||
2. **olevba Library** - No Excel required, uses oletools
|
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
|
- Excel > Options > Trust Center > Trust Center Settings
|
||||||
- Check "Trust access to the VBA project object model"
|
- Check "Trust access to the VBA project object model"
|
||||||
|
|
||||||
### Import VBA Code
|
### Import VBA Code
|
||||||
```bash
|
```bash
|
||||||
# Import from VBA/ directory back to Excel
|
# Import from VBA/ directory back to Excel or Access
|
||||||
python import_vba.py VBA/vba_metadata.json
|
python import_vba.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Set `TARGET_FILE` in `.env` to the target `.xlsm` or `.accdb` file path.
|
||||||
|
|
||||||
## VBA Code Architecture
|
## VBA Code Architecture
|
||||||
|
|
||||||
### BOM Data Model
|
### 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
|
- Cleans `Attribute` statements from exported code for readability
|
||||||
- Automatically categorizes modules by type (Standard/Class/Document/Form)
|
- 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)
|
- 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)
|
### 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
|
- **Critical fix for ClassModules**: Reconstructs `VERSION 1.0 CLASS` header before import
|
||||||
- **Encoding handling**: Uses GB18030 for temp files to prevent Chinese character corruption
|
- **Encoding handling**: Uses GB18030 for temp files to prevent Chinese character corruption
|
||||||
- Path recognition logic handles relative/absolute paths in metadata
|
- 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
|
## Platform Requirements
|
||||||
|
|
||||||
- **Windows required** for import functionality (COM interface)
|
- **Windows required** for import functionality (COM interface)
|
||||||
- **Microsoft Excel** required for COM-based extraction/import
|
- **Microsoft Excel** required for Excel COM-based extraction/import
|
||||||
- Cross-platform extraction possible with oletools (no Excel needed)
|
- **Microsoft Access** required for Access COM-based extraction/import
|
||||||
|
- Cross-platform extraction possible with oletools (Excel only, no Office needed)
|
||||||
|
|
||||||
## Git Workflow
|
## Git Workflow
|
||||||
|
|
||||||
The `.gitignore` excludes:
|
The `.gitignore` excludes:
|
||||||
- Virtual environment (`.venv/`)
|
- Virtual environment (`.venv/`)
|
||||||
- Build artifacts (`build/`, `dist/`)
|
- Build artifacts (`build/`, `dist/`)
|
||||||
- Project data (`Excel/`, `VBA/`)
|
- Project data (`Excel/`, `Access/`, `VBA/`)
|
||||||
- Claude temporary files (`.claude/`, `tmpclaude-*`)
|
- Claude temporary files (`.claude/`, `tmpclaude-*`)
|
||||||
|
|
||||||
Only commit code changes, not extracted VBA or Excel files.
|
Only commit code changes, not extracted VBA or Excel files.
|
||||||
|
|||||||
Reference in New Issue
Block a user