Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在excel中自动刷新导入的宏_Excel_Vba - Fatal编程技术网

在excel中自动刷新导入的宏

在excel中自动刷新导入的宏,excel,vba,Excel,Vba,我目前正在更新多个单独的excel文档以使用宏 虽然这些文件中的每一份都是独立的,但它们之间有许多共同的方程式。为了让我的生活更轻松,我将宏导出到一个bas文件中,然后再导入到每个后续文件中。我现在面临的问题是,有时这些方程式中的一些需要更改或更新。目前,这导致我必须转到每个excel文件,删除以前导入的bas文件并重新导入新文件。是否有办法通过某种形式的符号链接导入bas文件,或强制Excel检查文件的位置并确保bas文件是最新的 下面是一个简单的用例,因为我在漫谈中可能不太清楚: 文件1有一

我目前正在更新多个单独的excel文档以使用宏

虽然这些文件中的每一份都是独立的,但它们之间有许多共同的方程式。为了让我的生活更轻松,我将宏导出到一个bas文件中,然后再导入到每个后续文件中。我现在面临的问题是,有时这些方程式中的一些需要更改或更新。目前,这导致我必须转到每个excel文件,删除以前导入的bas文件并重新导入新文件。是否有办法通过某种形式的符号链接导入bas文件,或强制Excel检查文件的位置并确保bas文件是最新的

下面是一个简单的用例,因为我在漫谈中可能不太清楚:

文件1有一个等式 宏: 等式1:(值1+2)/1

这将导出到macros.bas

文档2使用相同的宏,因此只导入宏。bas: 等式1:(值1+2)/1

两天后,我被告知应修改方程式,使方程式除以值2。为此,执行以下步骤

步骤1) bas文件已更新,以便 等式1:(值1+2)/2

步骤2) 打开文档1和文档2 步骤3) 我必须删除旧的宏模块并重新导入新模块

有没有办法通过符号链接或强制excel自动刷新macros.bas中导入的宏来自动化步骤2-3


感谢您的回复。

根据Rory的建议,此问题的答案在于使用附加模块 下面的堆栈溢出文章可供参考。

这是我最终执行的解决方案

创建一个全新的工作簿。这将存储所有需要共享的模块

1 - In the Developer tab select Visual Basic.
2 - Create the module/modules I want to store my macros in and start writing them.
3 - Save the Workbook selecting the type "Excel Add-In (*.xlam)"
4 - Open the Workbook I wish to actually work on. 
5 - File -> Options. Select the Add-Ins tab (Or go to Developer tab -> Add-Ins)
6 - At the bottom under "Manage" ensure "Excel Add-Ins" is selected in the combo box and select Go
7 - Browse... and find the .xlam file you just saved.
8 - The macros should now be loaded. You can test them out in a cell or go to Developer -> Visual Basic. In the Visual Basic Project panel on the left of the new window, your Add-In should appear along with your current workbook.
9 - You may be required to restart Excel before using the Add-In Macros.
额外说明: 删除不需要的外接程序(假设您和我一样是新加入的)


正如Rory所建议的,这个问题的答案在于外接程序的使用 下面的堆栈溢出文章可供参考。

这是我最终执行的解决方案

创建一个全新的工作簿。这将存储所有需要共享的模块

1 - In the Developer tab select Visual Basic.
2 - Create the module/modules I want to store my macros in and start writing them.
3 - Save the Workbook selecting the type "Excel Add-In (*.xlam)"
4 - Open the Workbook I wish to actually work on. 
5 - File -> Options. Select the Add-Ins tab (Or go to Developer tab -> Add-Ins)
6 - At the bottom under "Manage" ensure "Excel Add-Ins" is selected in the combo box and select Go
7 - Browse... and find the .xlam file you just saved.
8 - The macros should now be loaded. You can test them out in a cell or go to Developer -> Visual Basic. In the Visual Basic Project panel on the left of the new window, your Add-In should appear along with your current workbook.
9 - You may be required to restart Excel before using the Add-In Macros.
额外说明: 删除不需要的外接程序(假设您和我一样是新加入的)


我觉得您应该使用外接程序来存储共享代码,而不是将其放入每个工作簿中。这样你只需要在一个地方更新代码。谢谢。我会研究它,并在完成后发布我的解决方案。我以前遇到过这个问题-我所做的是在我控制的集中工作簿中分发调用宏的工作簿,这样无论他们在多长时间前收到工作簿,它都将保持最新,因为它调用的是我可以管理的宏。这并不能解决手头的问题,但可以阻止它再次发生!我觉得您应该使用外接程序来存储共享代码,而不是将其放入每个工作簿中。这样你只需要在一个地方更新代码。谢谢。我会研究它,并在完成后发布我的解决方案。我以前遇到过这个问题-我所做的是在我控制的集中工作簿中分发调用宏的工作簿,这样无论他们在多长时间前收到工作簿,它都将保持最新,因为它调用的是我可以管理的宏。这并不能解决手头的问题,但可以阻止它再次发生!