从互联网笨重的打开Excel文档

我正在为我的公司写一个excel vba脚本,并且在顺利运行时遇到了一些麻烦。 为了让我的脚本做到这一点,我需要打开两个在我公司的Intranet上可用的Excel文档。 以下是我目前使用的代码:

Sub checkForGrids() Dim IE As Object Dim link As String On Error Resume Next Set groupGrid = Workbooks(Sheet2.Cells(3, 2).value) If groupGrid Is Nothing Then MsgBox ("The Service Area Grid is required for this tool to run. Attempting to open now.") Set IE = CreateObject("InternetExplorer.Application") link = Sheet2.Cells(3, 3) With IE .Visible = True .Navigate link End With End If Set groupGrid = Workbooks(Sheet2.Cells(4, 2).value) If groupGrid Is Nothing Then MsgBox ("The Service Area Grid is required for this tool to run. Attempting to open now.") Set IE = CreateObject("InternetExplorer.Application") link = Sheet2.Cells(4, 3) With IE .Visible = True .Navigate link End With End If End Sub 

这工作得很好,除了你必须在msgbox上单击确定,单击打开并等待,然后单击确定并打开第二个文档。 我的同事一popup就点击第二个确定button,导致错误。

有没有更顺利的方法来完成这个? 我更喜欢他们不必点击“打开”,但我一直无法find这样的方法。 谢谢

您可以通过不使其可见的方式静默运行IE,停止屏幕更新并使用Application.StatusBar方法通知用户正在发生的事情。

或者,您可以创build一个小的用户窗体,在非模态状态下popup,然后在所需的代码运行时隐藏。