From ab01835b0614ac78ba3f027f88f1138a2410f783 Mon Sep 17 00:00:00 2001 From: Misaka_Company Date: Thu, 19 Mar 2026 15:47:57 +0800 Subject: [PATCH] refactor: export form modules as .frm files to align with VBA conventions Change form module export from .cls to .frm extension to match standard VBA file conventions and align with import_vba.py expectations. This eliminates ambiguity between class modules and form modules. Co-Authored-By: Claude Sonnet 4.6 --- extract_vba.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/extract_vba.py b/extract_vba.py index 8a159bd..c476c13 100644 --- a/extract_vba.py +++ b/extract_vba.py @@ -253,7 +253,7 @@ class VBAExtractor: stream_path: 流路径 Returns: - 模块类型: Modules, ClassModules, DocumentModules + 模块类型: Modules, ClassModules, DocumentModules, Forms """ name_lower = module_name.lower() @@ -269,6 +269,10 @@ class VBAExtractor: if name_lower.startswith('cls') or name_lower.startswith('class'): return CLASS_MODULE_DIR + # 窗体模块 + if name_lower.startswith('userform') or name_lower.startswith('frm_') or name_lower.startswith('frm'): + return FORMS_DIR + # 根据stream_path判断 if stream_path: path_lower = stream_path.lower() @@ -276,6 +280,8 @@ class VBAExtractor: return DOCUMENT_MODULE_DIR elif 'class' in path_lower or 'cls' in path_lower: return CLASS_MODULE_DIR + elif 'form' in path_lower or 'userform' in path_lower: + return FORMS_DIR # 默认为标准模块 return STANDARD_MODULE_DIR @@ -309,7 +315,12 @@ class VBAExtractor: }.get(module_type, self.modules_dir) # 确定文件扩展名 - ext = '.cls' if module_type in [CLASS_MODULE_DIR, DOCUMENT_MODULE_DIR, FORMS_DIR] else '.bas' + if module_type == FORMS_DIR: + ext = '.frm' + elif module_type in [CLASS_MODULE_DIR, DOCUMENT_MODULE_DIR]: + ext = '.cls' + else: + ext = '.bas' # 清理文件名(移除已有扩展名) clean_name = module_name.replace('/', '_').replace('\\', '_')