Ошибка при компиляции в VBA "заданный тип не определен" - PullRequest
0 голосов
/ 04 февраля 2020

При компиляции кода в VBA я сталкиваюсь с ошибкой:

"пользовательский тип не определен"

Может кто-нибудь помочь мне решить эту проблему ?

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

1 Ответ

1 голос
/ 05 февраля 2020

Попробуйте следующее, чтобы получить желаемый результат. На этот раз вам не нужно ссылаться на библиотеки для выполнения скрипта.

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
...