+ Reply to Thread
Results 1 to 2 of 2

VBA Web Query

Hybrid View

  1. #1
    Registered User
    Join Date
    03-07-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    2

    VBA Web Query

    Morning guys,

    I have looked through this and other forums but no code seems to be working for my website and keeps giving errors i am unsure of.

    Simply put i am trying to complete a web query to pull data from a table, this information is behind a login page for both username and password. I get to the point of loading IE and then get an error message "the object invoked has disconnected from it's clients". The website is an internal webpage so i am unable to link it for your inspection but i am 95% sure i have the right form id's

    Sub GetTable()
    
    Dim ieApp As InternetExplorer
    Dim ieDoc As Object
    Dim ieTable As Object
    Dim clip As DataObject
    
    'create a new instance of ie
    Set ieApp = New InternetExplorer
    
    'you don’t need this, but it’s good for debugging
    ieApp.Visible = True
    
    'assume we’re not logged in and just go directly to the login page
    ieApp.Navigate "http://dss-gp-mida-002/MidasDS/login.jsp
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
    Set ieDoc = ieApp.Document
    
    'fill in the login form – View Source from your browser to get the control names
    With ieDoc.forms(0)
    .Username.Value = "Carterr"
    .Password.Value = "password"
    .submit
    End With
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
    'now that we’re in, go to the page we want
    ieApp.Navigate "http://dss-gp-mida-002/MidasDS/homepage.jsp"
    Do While ieApp.Busy: DoEvents: Loop
    Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
    'get the table based on the table’s id
    Set ieDoc = ieApp.Document
    Set ieTable = ieDoc.all.Item("sampletable")
    
    'copy the tables html to the clipboard and paste to teh sheet
    If Not ieTable Is Nothing Then
    Set clip = New DataObject
    clip.SetText "" & ieTable.outerHTML & ""
    clip.PutInClipboard
    Sheet1.Select
    Sheet1.Range("A1").Select
    Sheet1.PasteSpecial "Unicode Text"
    End If
    
    'close 'er up
    ieApp.Quit
    Set ieApp = Nothing
    
    End Sub

  2. #2
    Registered User
    Join Date
    03-07-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    2

    Re: VBA Web Query

    More details:

    This is what i find when i look for the form ID, the page is a JSP so unsure if this is the cause of the issues?

    var temp = document.loginform.username.value;

+ 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: 2
    Last Post: 01-24-2017, 11:22 AM
  2. Replies: 0
    Last Post: 03-22-2016, 05:14 PM
  3. Replies: 1
    Last Post: 09-08-2015, 08:12 PM
  4. Replies: 2
    Last Post: 02-01-2013, 04:21 PM
  5. [SOLVED] Loop through list, perform web query and save each query on its own page
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2012, 07:50 AM
  6. Problem with selecting range with in query table after query refresh
    By shooter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-31-2012, 11:55 AM
  7. Web Query - Change a word in query to form a new query
    By scottymelloty in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2011, 04:13 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