在 VBA "set-defined type not defined" 中编译时出错

Error in compiling in VBA "set-defined type not defined"

编译 VBA 中的代码时,我遇到的错误是

"user-defined type not defined"

谁能帮我解决这个问题?

Sub import_ZipRecruiter()

Dim IE As SHDocVw.InternetExplorer
Set IE = New InternetExplorer
 IE.Visible = True
IE.Navigate "https://www.ziprecruiter.com/candidate/search? 
search=ax&location=USA&days=5&refine_by_salary=&refine_by_tags=&refine_by_title=&refine_by_org_name="

Do While IE.ReadyState <> READYSTATE_COMPLETE

DoEvents
Loop

Sheets("Sheet3").Select
Cells.Select
Selection.ClearContents



Dim idoc As HTMLDocument
Set idoc = IE.Document
Dim r As Long, c As Long

Dim just_job_title As IHTMLElement
Dim dts As IHTMLCollection
Set dts = idoc.getElementsByClassName("just_job_title")
c =1 ; r=1

For Each just_job_title In dts

Sheets("Sheet3").Cells(r, c) = just_job_title.innerText
c = c + 1
Next just_job_title

End Sub

尝试以下操作以获得所需的输出。这次您不需要引用任何库来执行脚本。

Sub GetJobTitles()
    Const Url$ = "https://www.ziprecruiter.com/candidate/search?%20%20search=ax&location=USA&days=5&refine_by_salary=&refine_by_tags=&refine_by_title=&refine_by_org_name="
    Dim post As Object, R&

    With CreateObject("InternetExplorer.Application")
        .Visible = True
        .navigate Url
        While .Busy Or .readyState < 4: DoEvents: Wend
        For Each post In .document.getElementsByTagName("article")
            R = R + 1: Cells(R, 1) = post.getElementsByClassName("just_job_title")(0).innerText
            Cells(R, 2) = post.getElementsByClassName("name")(0).innerText
            Cells(R, 3) = post.getElementsByClassName("location")(0).innerText
        Next post
        .Quit
    End With
End Sub