excel vba copying fedex tracking information

I want to copy into Excel 3 tracking information tables that website generates when I track a parcel. I want to do it through Excel VBA. I can write a loop and generate this webpage for various tracking numbers. But I am having a hard time copying tables - the top table, travel history and shipments track table. Any solution? In my vba code last 3 lines below are giving an error :( - run time error '438' Object doesn't support this property or error.

Sub final() Application.ScreenUpdating = False Set ie = CreateObject("InternetExplorer.Application") my_url = "https://www.fedex.com/fedextrack/index.html?tracknumbers=713418602663&cntry_code=us" With ie .Visible = True .navigate my_url Do Until Not ie.Busy And ie.readyState = 4 DoEvents Loop End With ie.document.getElementById("detailsBody").Value ie.document.getElementById("trackLayout").Value ie.document.getElementById("detail").Value End Sub 
6,960 3 3 gold badges 52 52 silver badges 83 83 bronze badges asked Apr 7, 2014 at 16:59 user2543622 user2543622 6,546 29 29 gold badges 104 104 silver badges 172 172 bronze badges

1 Answer 1

.Value is not a method available in that context. also, you will want to assign the return value of the method call to a variable. Also, you should declare your variables :)

I made some modifications and include one possible way of getting data from one of the tables. YOu may need to reformat the output using TextToColumns or similar, since it prints each row in a single cell.

I also notice that when I execute this, the tables have sometimes not finished loading and the result will be an error unless you put in a suitable Wait or use some other method to determine when the data has fully loaded on the webpage. I use a simple Application.Wait

Option Explicit Sub final() Dim ie As Object Dim my_url As String Dim travelHistory As Object Dim history As Variant Dim h As Variant Dim i As Long Application.ScreenUpdating = False Set ie = CreateObject("InternetExplorer.Application") my_url = "https://www.fedex.com/fedextrack/index.html?tracknumbers=713418602663&cntry_code=us" With ie .Visible = True .navigate my_url '## I modified this logice a little bit: Do While .Busy And .readyState <> 4 DoEvents Loop End With '## Here is a simple method wait for IE to finish, you may need a more robust solution ' For assistance with that, please ask a NEW question. Application.Wait Now() + TimeValue("0:00:10") '## Get one of the tables Set travelHistory = ie.Document.GetElementByID("travel-history") '## Split teh table to an array history = Split(travelHistory.innerText, vbLf) '## Iterate the array and write each row to the worksheet For Each h In history Range("A1").Offset(i).Value = h i = i + 1 Next ie.Quit Set ie = Nothing End Sub