Blue Dartのようなさまざまなサービスプロバイダから私の通常の宅配便の配送状況を自動化したいと思います。VBAを使用して現在の開いているWebページからデータをエクスポートできません
私はDocket番号を持っています。私はVBAを使って同じことを試みましたが、ウェブページからデータを取得できませんでした。
マイコードはホームページのセルからDocket番号を入力してから、配送ステータスが表に記載されている他のページにリダイレクトされます。
Sub GetCourseList()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
Dim IEWindows As SHDocVw.ShellWindows
Dim IEwindow As SHDocVw.InternetExplorer
Dim IEDocument As MSHTML.HTMLDocument
Dim BreadcrumbDiv As MSHTML.HTMLElementCollection
Set IEWindows = New SHDocVw.ShellWindows
'create new instance of IE. use reference to return current open IE if
'you want to use open IE window. Easiest way I know of is via title bar.
IE.Navigate "http://www.bluedart.com/maintracking.html"
'go to web page listed inside quotes
IE.Visible = True
While IE.busy
DoEvents 'wait until IE is done loading page.
Wend
IE.Document.All("numbers").Value = ThisWorkbook.Sheets("sheet1").Range("A1")
Application.SendKeys "~"
Dim URL As String
Dim qt As QueryTable
Dim ws As Worksheet
Set ws = Worksheets.Add
For Each IEwindow In IEWindows
If InStr(IEwindow.LocationURL, "your URL or some unique string") <> 0 Then ' Found it
Set IEDocument = IEwindow.Document
URL = IEwindow.LocationURL
Set qt = ws.QueryTables.Add(_
Connection:="URL;" & URL, _
Destination:=Range("F1"))
With qt
.RefreshOnFileOpen = True
.Name = "bluedart"
.FieldNames = True
.WebSelectionType = xlAllTables
.Refresh BackgroundQuery:=False
End With
End If
Next
End Sub
シートの値をテストするための値はありません。正確に動作しないものはありません。いくつかの行にエラーがありますか?また、プロシージャの最上部で 'Option Explicit'を使って、' IE.busyまたはIE.Readystate <> 4'、 'ThisWorkbook.Sheets(" sheet1 ")。Range(" A1 ")。value2'を呼び出し、' SendKeys'それは信頼できないためです。これらは良い習慣であり、この特定の問題に対する直接の解決策ではありません。 –
追跡番号50419480764または50419669171の例:私はどんなエラーも出ていませんが、たとえそれが空白であるかのようにデータを取得しないとしても、 – Eager