本周我遇到了一个问题。在我的情况下,我尝试通过宏更新报表生成器,然后刷新文件以更新枢轴。我想为多个工作簿执行此操作。
我使用了这个宏:
Application.Wait (Now() + TimeValue("00:00:02"))
Dim addIn As COMAddIn
Dim automationObject As Object
Dim success As String
Set addIn = Application.COMAddIns("ReportBuilderAddIn.Connect")
Set automationObject = addIn.Object
success = automationObject.RefreshAllRequests(ActiveWorkbook)
Application.Wait (Now() + TimeValue("00:00:10"))
Sheets("Week on week 2015").Select
ActiveWorkbook.RefreshAll
ActiveWorkbook.RefreshAll
ActiveWorkbook.RefreshAll
Range("F8").Select
ActiveWorkbook.RefreshAll
ActiveWorkbook.Save
ActiveWindow.Close
似乎第二个Application.Wait正在搞砸整个宏。当我不使用第二个Application.Wait问题是,当Report Builder仍在运行时,RefreshAll将启动得太早。第二个文件打开时,第一个文件将关闭并保存。这是行不通的,因为第一个文件仍然在运行Report Builder。
结论: 有没有人知道在报表生成器完成更新时等待/暂停宏的更好方法? 或者有人知道如何调用成功线并通过识别成功线的完成来激活宏的第二部分吗?
答案 0 :(得分:0)
我找到了一条可以证明解决方案的线路。 Report Builder excel插件完成了它的工作但不幸的是我收到了错误
行:
Threading.thread.Sleep(60000)
错误:
对象需要424
使用的VBA:
Application.Wait (Now() + TimeValue("00:00:02"))
Application.CommandBars("Adobe Report Builder Toolbar").Controls(5).Execute
Application.Wait (Now() + TimeValue("00:00:010"))
Threading.thread.Sleep (60000)
Sheets("Week on week 2015").Select
ActiveWorkbook.RefreshAll
ActiveWorkbook.RefreshAll
ActiveWorkbook.RefreshAll
Range("F8").Select
ActiveWorkbook.RefreshAll
ActiveWorkbook.Save
ActiveWindow.Close
有人有解决方案吗?