我的问题基本上就是标题......
我打开了一个内部运行宏的工作簿。 当我尝试在此过程中打开另一个工作簿时,它将永远加载。
问题:如果我在工作簿中运行了宏,是否有办法打开另一个工作簿?
关于正在运行的代码,我确保使用 ThisWorkbook 面额,这样就不会因打开其他工作簿而改变它。
为了您的信息,我的代码是:
Option Explicit
Private objIE As SHDocVw.InternetExplorer
Sub MySub()
'i)Declaration of the variables
Dim i As Integer
Dim Path As String ' stores the path
'ii)Path to the platform
Path = "https://www.mywebsite.com"
'1)Navigate to the platform
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.navigate Path
Do
Loop While objIE.readyState <> READYSTATE_COMPLETE
'3)Check Price
Start:
Do
Loop While CLng(objIE.document.getElementsByClassName("Myclassname")(0).innerText) > 4200 And CLng(objIE.document.getElementsByClassName("Myclassname")(0).innerText) < 4500
'4) Write down the value in Excel
i = i + 1
ThisWorkbook.Sheets("Tabelle1").Cells(7 + i, 4) = CLng(objIE.document.getElementsByClassName("Myclassname")(0).innerText) ' Value
ThisWorkbook.Sheets("Tabelle1").Cells(7 + i, 3) = Right(Now, 8) ' Time
ThisWorkbook.Sheets("Tabelle1").Cells(7 + i, 2) = Date ' Date
Application.Wait Now + TimeSerial(0, 0, 10)
GoTo Start
End Sub