getElementById innerHTML 运行时错误 91

getElementById innerHTML Runtine error 91

我正在尝试使用 excel vba 从 html 行(如下所示)中提取文本。

<textarea class="textareaMod task-title" id="task-description">software Developemnt</textarea>

每次代码运行时我都会收到运行时错误 91。下面是我的代码的一部分。非常感谢任何解决此问题的帮助。

Dim ie As InternetExplorer
Dim html As HTMLDocument
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate URLstr
Do While ie.READYSTATE <> READYSTATE_COMPLETE
Application.StatusBar = "Trying to connect to the source..."
DoEvents
Loop

Set html = ie.document
Set ie = Nothing
Application.StatusBar = ""
Dim title, header As String

title = html.getElementById("task-description").innerHTML
Activesheet.Range("B2").Value = title

谢谢 SIM 和 Cindy!这对我有用:

Dim Title As Object
Dim TitleTxt As String 
Set Title = html.getElementById("task-description") 
TitleTxt = Title.innerText 
Activesheet.Range("B2").Value = Title