-1

I am trying to extract the text from an html line (shown below) using excel vba.

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

I am getting Runtime error 91 every time the code runs. Below is a part of my code. Any help to resolve this is much appreciated.

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
Raji
  • 53
  • 1
  • 8
  • Possible duplicate of [VBA: Run time error '91'?](https://stackoverflow.com/questions/18927297/vba-run-time-error-91) – fbueckert May 15 '18 at 14:10
  • Try this and make sure to create newline from colon `Dim title as object : set title = html.getElementById("task-description") : MsgBox title.innertext` – SIM May 15 '18 at 14:19
  • Don't `Set ie = Nothing` if you're still going to be using an object the depends on `ie` (`html`). – Cindy Meister May 15 '18 at 14:47

1 Answers1

1

Thanks SIM and Cindy ! This worked for me:

Dim Title As Object
Dim TitleTxt As String 
Set Title = html.getElementById("task-description") 
TitleTxt = Title.innerText 
Activesheet.Range("B2").Value = Title
QHarr
  • 83,427
  • 12
  • 54
  • 101
Raji
  • 53
  • 1
  • 8