无法find正确的Excel文件库引用错误
每次我打开这个Excel文件,我都会得到这个在屏幕截图1和屏幕截图2中的错误。
当我点击确定后,我需要编码窗口,并要求我select图书馆。
我尝试了一切,使其工作,但没有运气。
截图一和截图二:
确保这些引用是以这个优先顺序。
HTML和Internet控件需要在OLE自动化之上。
如果此后仍然存在此问题,请在Office安装上运行修复,并刷新可能已损坏的.DLL文件。
更新:7/6/2017
上面的透视答案将重新关联引用并允许脚本进行编译。
不过,还有一个更好的办法。
当VBA脚本与不同平台(OS和MS Office版本)不同的其他计算机共享并使用早期绑定时,会发生此问题。 早期绑定减less了延迟,并且是仅用于一台计算机时的正确方法。
答案是在脚本中使用后期绑定格式,而不是select任何引用。 将对象以外的任何数据types对象更改回对象,并使用以下格式:
Sub Late_Binding() Dim IE_App_obj As Object Dim MyShell_obj As Object Dim IE_Window_obj As Object Dim Windows_cnt As Long Dim x_cnt As Variant Dim HTML_Element_obj As Object Set IE_App_obj = CreateObject("InternetExplorer.Application") 'Use IE_App_obj to Navigate to webpage and control it.' Set MyShell_obj = CreateObject("Shell.Application") 'Use MyShell_obj to find an existing webpage and control it.' Let Windows_cnt = MyShell.Windows.Count For x_cnt = Windows_cnt - 1 To 0 Step -1 On Error Resume Next If Instr(MyShell_obj.Windows(x_cnt).Document.Title,"WebPage_Title") > 0 Then Set IE_Window_obj = MyShell_obj.Windows(x_cnt) Exit For End If Next Set HTML_Element_obj = IE_Window_obj.Document.getElementByID("ID_text") End Sub
延迟会增加,但稳定性也会增加。