VBA EXCEL 在不打开工作簿的情况下更新另一个工作簿中的单元格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13510932/
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
VBA EXCEL update cell in another workbook without opening the workbook
提问by Nev
I have a directory with list of Workbooks, I want to loop through them withouthopening them and update a Cell in a certain Sheet
我有一个工作簿的名单目录,我想遍历他们withouth的打开并将更新在一定的工作表单元格
I have tried to use
我试过用
Dim wb As Workbook
Set wb = Workbooks("Z:\dir\bla.xls") 'THIS WILL COME TRHOUGH WHEN I LOOP
Set ws2 = wb.Sheets("TestSheet") 'SHEET NAME
Set CurCell_2 = ws2.Range("A1")
CurCell_2.Value = 5
The Problem comes it only works when I have the Workbook already open. I can use:
问题来了,它只有在我已经打开工作簿时才有效。我可以用:
Workbooks.Open
But then It opens up in the background and takes to long to run through them all.
但随后它在后台打开,需要很长时间才能浏览所有内容。
Can anyone help please
任何人都可以帮忙吗
回答by ApplePie
You cannot do that without opening the workbooks. However, I have found in my case that using Application.EnableEvents
and setting it to false sped up greatly the process because we have macros on workbook open event.
如果不打开工作簿,您就无法做到这一点。但是,在我的案例中,我发现使用Application.EnableEvents
并将其设置为 false 大大加快了进程,因为我们在工作簿打开事件中有宏。