简体   繁体   English

VBA EXCEL 在不打开工作簿的情况下更新另一个工作簿中的单元格

[英]VBA EXCEL update cell in another workbook without opening the workbook

I have a directory with list of Workbooks, I want to loop through them withouth opening 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任何人都可以帮忙吗

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 大大加快了进程,因为我们在工作簿打开事件上有宏。

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

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