+ Reply to Thread
Results 1 to 2 of 2

unable to EXPORT data from current open web page using VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    11-27-2016
    Location
    Mumbai
    MS-Off Ver
    2010
    Posts
    1

    unable to EXPORT data from current open web page using VBA

    I want to automate my delivery status for my regular courier from various service provider like Blue Dart.

    I have Docket Numbers; I tried the same using VBA but it is unable to fetch data from webpage.

    My code enter the Docket number from cell in home page, then it redirects to other page where delivery status is mentioned in table.
    Eg of Docket Number for tracking 50419480764 or 50419669171; I am not getting any error but it even doesn't fetch the data as if it is blank.


    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

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: unable to EXPORT data from current open web page using VBA

    This one is great
    If InStr(IEwindow.LocationURL, "your URL or some unique string") <> 0 Then  ' Found it

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 11-10-2016, 10:18 AM
  2. File shows 1GB data, but unable to open same
    By vinistring in forum Excel General
    Replies: 6
    Last Post: 09-22-2015, 04:06 PM
  3. [SOLVED] Unable to add data via userform when another worksheet is open
    By Janto724 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-25-2013, 09:11 AM
  4. Unable to set the current page property of Pivot Field class
    By sajidb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2012, 02:08 PM
  5. Unable to export data greater than 65000 row
    By naveen4pundir in forum Access Tables & Databases
    Replies: 8
    Last Post: 03-30-2012, 11:36 AM
  6. [SOLVED] Export data saving page set ups
    By PiPPo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-14-2005, 02:05 PM
  7. [SOLVED] VBA Code for a pivot table to open database and to reference table current page
    By Pete Straman Straman via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-21-2005, 12:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1