VBA 项目资源管理器仍显示由宏关闭的 excel 工作簿

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7722362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 14:13:37  来源:igfitidea点击:

VBA project explorer still showing the excel workbooks which are closed by the macro

excelvba

提问by niko

I have created a macro that opens a excel workbook and performs some operations and then at the end it closes the file.The macro is running fine.

我创建了一个宏,它打开一个 excel 工作簿并执行一些操作,然后在最后关闭文件。宏运行良好。

Now, when I open my VBA Project explorer in the vba editor. It shows the list of files that have been opened by the macro even though they are closed. How do i remove them from the project explorer window ? why its still showing the excel workbooks, which are already closed ? is there anyway to fix it or its a limitation?

现在,当我在 vba 编辑器中打开我的 VBA 项目资源管理器时。它显示已被宏打开的文件列表,即使它们已关闭。如何从项目资源管理器窗口中删除它们?为什么它仍然显示已经关闭的excel工作簿?有没有办法修复它或它的限制?

回答by niko

I Found the answer myself sorry to waste some space here . I request to close these or delete these post, if you think its not neccessary Thanks !

我自己找到了答案,很抱歉在这里浪费了一些空间。我要求关闭这些或删除这些帖子,如果你认为它没有必要,谢谢!

   Dim Excel_workbook as excel.workbook
   set Excel_workbook = workbooks.open("somefile name");
   ' some code goes here 
   ' at the end write the below statement
   set Excel_workbook = Nothing 'worked, I found at the 12 page of google search

This is the link that helped me http://www.mrexcel.com/forum/showthread.php?t=50086

这是帮助我的链接http://www.mrexcel.com/forum/showthread.php?t=50086

回答by jbmb2000

I know this is an old topic but I had the same thing happening but it wasn't because of the same issue.

我知道这是一个老话题,但我发生了同样的事情,但这不是因为同样的问题。

In my case the problem was the Microsoft Data Streamer for Excel add-in - once I deactivated it the projects disappeared from VBA when it's workbook was closed.

在我的情况下,问题是 Microsoft Data Streamer for Excel 加载项 - 一旦我停用它,当它的工作簿关闭时,项目就会从 VBA 中消失。