Excel 使用 VBA 自动执行 TFS 更新在 Workbook_Open 函数中不起作用
Excel's automating a TFS update using VBA won't work in Workbook_Open function
我正在尝试自动化工作簿,以便在打开它时自动更新 TFS 数据并发送电子邮件。我可以使用宏成功更新 TFS 数据(在此 blog) however when I run the code from the Workbook_Open event it errors out with "Run-time error '-2147467259 (80004005)' Method 'execute' of object '_CommandBarButton' failed". I looked at How do I resolve a VBA 'Method Execute of a [TFS Excel Add-in CommandBarButton] failed' Run-time error 上找到代码,但该解决方案对我不起作用。这对我来说实际上很有意义,因为工作簿尚未实际连接到 TFS - 那在 Workbook_Open 完成后发生。
我的问题是,建立 TFS 数据库连接后是否有事件可以调用我的代码,或者有没有办法先强制 TFS 连接?我试过 Application.Wait 和睡眠,但这只会延迟 TFS 数据库连接。
谢谢!
I have tried doing Application.Wait and Sleep, but that just delays the TFS Database connection.
那是因为这些方法本质上是暂停当前(一个也是唯一的)线程;与此同时,他们不会让任何其他(非VBA)代码运行。
the workbook hasn't actually connected to TFS yet - that happens AFTER the Workbook_Open completes.
听起来你需要推迟执行。将 CommandButton.Execute
代码移动到另一个过程,然后使用 Application.OnTime 安排该过程的执行,比如 5 秒后 - 假设您将有问题的代码拉到某个 UpdateTFS
过程:
Application.OnTime DateTime.DateAdd("s", 5, DateTime.Now), "UpdateTFS"
我正在尝试自动化工作簿,以便在打开它时自动更新 TFS 数据并发送电子邮件。我可以使用宏成功更新 TFS 数据(在此 blog) however when I run the code from the Workbook_Open event it errors out with "Run-time error '-2147467259 (80004005)' Method 'execute' of object '_CommandBarButton' failed". I looked at How do I resolve a VBA 'Method Execute of a [TFS Excel Add-in CommandBarButton] failed' Run-time error 上找到代码,但该解决方案对我不起作用。这对我来说实际上很有意义,因为工作簿尚未实际连接到 TFS - 那在 Workbook_Open 完成后发生。
我的问题是,建立 TFS 数据库连接后是否有事件可以调用我的代码,或者有没有办法先强制 TFS 连接?我试过 Application.Wait 和睡眠,但这只会延迟 TFS 数据库连接。
谢谢!
I have tried doing Application.Wait and Sleep, but that just delays the TFS Database connection.
那是因为这些方法本质上是暂停当前(一个也是唯一的)线程;与此同时,他们不会让任何其他(非VBA)代码运行。
the workbook hasn't actually connected to TFS yet - that happens AFTER the Workbook_Open completes.
听起来你需要推迟执行。将 CommandButton.Execute
代码移动到另一个过程,然后使用 Application.OnTime 安排该过程的执行,比如 5 秒后 - 假设您将有问题的代码拉到某个 UpdateTFS
过程:
Application.OnTime DateTime.DateAdd("s", 5, DateTime.Now), "UpdateTFS"