简体   繁体   English

在 excel 和 word 之间共享宏模块

[英]Share macros modules between excel and word

Over the last two years I have written several macros for excel and word and saving them in normal.dotm and personal.xlsm.在过去的两年里,我为 excel 和 word 编写了几个宏,并将它们保存在 normal.dotm 和 personal.xlsm 中。 I have some modules that handles filereading,database interactions, html parsing and so on, these modules are exact the same both in word and excel.我有一些处理文件读取、数据库交互、html 解析等的模块,这些模块在 word 和 excel 中完全相同。 Untill now I have just copied them between those two applications.到目前为止,我只是在这两个应用程序之间复制了它们。 Is it possible to somehow have them stored in one locations(as a library) and then use them in both applications?是否有可能以某种方式将它们存储在一个位置(作为库)然后在两个应用程序中使用它们?

I guess it could be possible to write a module that export it to a given location and then deletes them for so import them again to make sure that I remember to copy all modules between those two, but this seems like the wrong way to do it.我想有可能编写一个将其导出到给定位置的模块,然后删除它们以便再次导入它们以确保我记得在这两个模块之间复制所有模块,但这似乎是错误的方法.

Store the common functions in a vbs file and load them from macros.将常用函数存储在 vbs 文件中并从宏中加载它们。 Of course you may require to revisit the functions to make sure they do not have excel or word specific code.当然,您可能需要重新访问这些函数以确保它们没有 excel 或 word 特定代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM