前提・実現したいこと
発生している問題・エラーメッセージ
実行時エラー'13': 型が一致しません
該当のソースコード
microsoft
1Option Explicit 2 3Sub main() 4 '=====宣言====== 5 Dim objIE As InternetExplorer 6 Dim strUrl As String 7 Dim intRowCnt As Integer 8 Dim objLink As Variant 9 Dim bLoopEnd As Boolean 10 Dim htmlDoc As HTMLDocument 11 Dim Lists As Variant 12 Dim rng As Range 13 14 15 16 17 Application.OnTime Now() + TimeValue("00:01:00"), "main" 18 19 Range("B1") = "スポーツ" 20 21 Range("C1") = "自然哲学" 22 23 Range("D1") = "健康法" 24 25 strUrl = "https://www.amazon.co.jp/dp/4910001050" 26 27 Call getpage(objIE, strUrl) 28 29 Set htmlDoc = objIE.document 30 31 intRowCnt = 2 32 33 Call WaitResponse(objIE) 34 Call set_webdata(objIE, intRowCnt) 35 36 37 38End Sub 39 40Sub set_webdata(objIE As Object, rowcnt As Integer) 41 42 Dim intRowStart As Integer 43 Dim intRowCnt As Integer 44 Dim str As Variant 45 Dim htmlDoc As HTMLDocument 46 Dim elements As IHTMLElementCollection 47 48 Set htmlDoc = objIE.document 49 50 51 intRowStart = rowcnt 52 intRowCnt = rowcnt 53 54 For Each str In htmlDoc.getElementsByClassName("zg_hrsr_rank")(1).innerHTML 55 Debug.Print elements(1).Content 56 Cells(intRowCnt, 2).Value = str.innerHTML 57 intRowCnt = intRowCnt + 1 58 Next 59 intRowCnt = intRowStart 60 61 For Each str In htmlDoc.getElementsByClassName("zg_hrsr_rank")(2).innerHTML 62 Debug.Print elements(2).Content 63 Cells(intRowCnt, 3).Value = str.innerHTML 64 intRowCnt = intRowCnt + 1 65 Next 66 intRowCnt = intRowStart 67 68 For Each str In htmlDoc.getElementsByClassName("zg_hrsr_rank")(3).innerHTML 69 Debug.Print elements(3).Content 70 Cells(intRowCnt, 4).Value = str.innerHTML 71 intRowCnt = intRowCnt + 1 72 Next 73 74 75End Sub 76 77Sub getpage(ByRef objIE As Object, strUrl As String) 78 79 Set objIE = CreateObject("Internetexplorer.Application") 80 81 objIE.Visible = True 82 83 objIE.navigate (strUrl) 84 85 Call WaitResponse(objIE) 86 87End Sub 88Sub WaitResponse(objIE As Object) 89 90 Do While objIE.Busy = True Or objIE.readyState < READYSTATE_COMPLETE 91 DoEvents 92 Loop 93End Sub 94
試したこと
改行するプログラムを消してみたりなどしました
補足情報(FW/ツールのバージョンなど)
ofice excel 365 標準モジュール
回答2件
あなたの回答
tips
プレビュー