fix: address code review issues for Access support

- Fix import_vba_access() to actually save database via DoCmd.Save()
- Update stale module docstring in extract_vba.py
- Validate file extensions in get_file_type() instead of silently
  defaulting to excel
- Scan both Excel/ and Access/ directories in interactive mode

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

View File

@@ -50,11 +50,16 @@ def get_file_type(file_path: Path) -> str:
Returns:
'access''excel'
Raises:
ValueError: 不支持的文件扩展名
"""
ext = file_path.suffix.lower()
if ext in ACCESS_EXTENSIONS:
return 'access'
return 'excel'
if ext in EXCEL_EXTENSIONS:
return 'excel'
raise ValueError(f"不支持的文件类型: {ext}(支持: .xlsm, .xls, .xlsb, .accdb, .mdb")
class VBAImporter:
@@ -411,8 +416,7 @@ class VBAImporter:
print("\n正在保存...")
try:
import time
time.sleep(1) # 等待 VBE 完成
access.DoCmd.Save()
print("已保存更改。")
except Exception as e:
print(f"保存时出错: {e}")