如何将代码更改保存到 Excel VBA 加载项?

发布于 2024-07-21 07:32:48 字数 156 浏览 4 评论 0原文

我已经在 VBA 中为 Excel 制作了一个插件,现在我需要更改代码,但文件无法保存。 我打开 .xlam 文件,进行更改,按 ctrl-S 保存,没有弹出错误,然后关闭。 但当我重新打开时,我所做的任何更改都不存在。 是什么赋予了? 是否有一些特殊的方法我必须保存加载项才能使更改生效?

I've made an add-in for Excel in VBA and now I need to make changes to the code, but the file won't save. I open the .xlam file, I make the changes, ctrl-S to save with no errors popping up, close down. But when I reopen, none of the change I made are there. What gives? is there some special way I have to save an add-in to make changes stick?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

在巴黎塔顶看东京樱花 2024-07-28 07:32:48

在 VB 编辑器中,在“项目资源管理器”窗格中选择项目,然后在“立即窗口”(Ctrl + G) 中输入以下行并按 Enter:

ThisWorkbook.Save

In the VB editor, select the project in the Project Explorer pane, then in the Immediate Window (Ctrl + G) enter this line and press Enter:

ThisWorkbook.Save

白色秋天 2024-07-28 07:32:48

我曾遇到过看起来加载项未保存的情况。 我必须卸载加载项,重新启动 Excel,然后重新加载加载项。 保存的更改就在那里,只是在重新加载加载项之前才显示。

I have had occurrences where it did not look like the Add-In was saved. I had to unload the Add-In, restart Excel, and then reload the Add-In. The saved changes were there, just not shown until the Add-In was reloaded.

つ低調成傷 2024-07-28 07:32:48

当进行默认 Excel 保存时,我遇到了加载项未保存的问题; 相反,您应该确保始终从 VBA 编辑器内部保存。 除此之外,请确保您没有选中“锁定项目以供查看”复选框或添加密码 - 这些都可以在“项目属性”对话框的“保护”选项卡上找到,即“工具”中的第 5 项“ 菜单。

I've had issues with add-ins not saving when the default Excel save is made; instead, you should make sure that you always save from inside the VBA editor. Beyond that, make sure you haven't checked the "Lock project for viewing" checkbox or added a password -- these can both be found on the "Protection" tab of the "Project Properties" dialog, the 5th item in the "tools" menu.

云柯 2024-07-28 07:32:48

我在 .xlam 文件的 Sheet1 上有一个按钮,其中包含以下代码:

Private Sub CommandButton3_Click()
    ThisWorkbook.IsAddin = True
    ThisWorkbook.Saved = True
End Sub

当我想要保存 .xlam 文件时,我在 Project Explorer 窗口中选择 ThisWorksheet,然后将 IsAddin 属性的值更改为 false,这显示 .xlam 文件的sheet1。 我单击该按钮,将其更改回插件文件并保存代码。

I 've have a button on Sheet1 of the .xlam file with the following code:

Private Sub CommandButton3_Click()
    ThisWorkbook.IsAddin = True
    ThisWorkbook.Saved = True
End Sub

When I want to save the .xlam file, I select ThisWorksheet in the Project Explorer window, and then change the value of the IsAddin property to false, which displays sheet1 of the .xlam file. I click the button, which changes it back to an Addin file and saves the code.

青瓷清茶倾城歌 2024-07-28 07:32:48

我还遇到了以下问题:VBE 不会在我创建的 .xlam 加载项中保存代码更改。 我偶然发现,如果有任何工作簿打开(隐藏的 .xlam 除外),则 VBE 保存不会发生,但如果所有其他工作簿都关闭,则 VBE 会保存加载项中的更改。 保存并关闭所有工作簿以保存代码更改,然后重新打开它们是一种尴尬的解决方法,但它比总是导出更改的模块、关闭 Excel、重新打开它和 VBE,以及导入保存的 .bas 文件要快。 也许这给了某人(在微软?)一个暗示为什么 VBE 没有像它应该的那样保存。

I have also had the issue that the VBE does not save code changes in a .xlam add-in I created. By chance I discovered that if there are any workbooks open (other than the hidden .xlam), the VBE save does not happen, but if all other workbooks are closed, then the VBE does save changes in the add-in. It's an awkward workaround to save and close all workbooks in order to save the code changes, then reopen them, but it is faster than always exporting the changed modules, closing Excel, reopening it and the VBE, and importing the saved .bas files. Maybe that gives someone (at Microsoft?) a hint of why the VBE isn't saving as it should.

谷夏 2024-07-28 07:32:48

打开VBA编辑器-> 打开您的项目 -> Microsoft Excel 对象 -> ThisWorkbook 及其属性将 IsAddin 更新为 false,并保存打开的 Excel 宏文件,然后再次打开宏文件中的代码,并将 IsAddin 再次更改为 true,以在 2024 年修复此问题。

Open the VBA editor -> Open your project -> Microsoft Excel Objects -> ThisWorkbook and on the properties updated IsAddin to false and save the excel macro file that gets opened and again open code from the macro file and changed IsAddin to true again to fix this issue on 2024.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文