Consulting

Results 1 to 8 of 8

Thread: Solved: web navigation

  1. #1
    VBAX Tutor
    Joined
    Jun 2012
    Posts
    269
    Location

    Solved: web navigation

    I am trying to pull a series of reports from the web using VBA.

    I have successfully logged on to the account, navigated to where I see the report button, now I need to figure out the element I need to click to open the report and how to save the report to my hard drive.

    Attached is a screen shot of the web page...

    I am trying to "Click" on the summary report in the upper right corner...

    Attached is the page source.

    I would also like to be able to "click" on the July 09,2010 tab and click the same summary report.

    Once I figure all this out, I believe I can do everything else I need.

    Thanks for your help...

    The code I am using to log on etc is as follows (I have deleted the password/username etc):

    [VBA]Sub test()
    Dim Doc As HTMLDocument
    Dim ie As InternetExplorer
    Dim loginForm As HTMLFormElement
    Dim usernameInputBox As HTMLInputElement
    Dim passwordInputBox As HTMLInputElement
    Dim signinbutton As HTMLImg
    Dim sURL As String


    sURL = "test2.hyattselectreports.lraqa.com/" '"https://test2.lraqa.com/"


    Set ie = New InternetExplorer
    ie.navigate sURL
    ie.Visible = True

    While ie.Busy
    DoEvents
    Wend


    Do
    DoEvents
    Loop Until ie.readyState = READYSTATE_COMPLETE


    Set Doc = ie.document
    On Error Resume Next

    Set loginForm = Doc.forms(0)
    Set usernameInputBox = loginForm.elements("username")
    usernameInputBox.Value = "" 'I have deleted this for security reasons

    Set passwordInputBox = loginForm.elements("password")
    passwordInputBox.Value = "" 'I have deleted this for security reasons

    loginForm.elements("LoginButton").Click




    Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy
    DoEvents
    Loop


    '************************************************************************** *****
    ' will have to loop through all properties listed in a column on sheet 1 or so *
    '************************************************************************** *****
    ie.navigate "http://test2.hyattselectreports.lraqa.com/index.php?page=&propid=" & Sheet1.Cells(1, 1)
    'I put 33808 in cell a1 ... I will do this as a loop and populate the appropriate cells with the property id's


    Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy
    DoEvents
    Loop



    'need code here to "click" on the summary report button to navigate to that page... Thanks!




    End Sub


    [/VBA]

    Thanks for any help/suggestions.

    Josh / CodeNinja.
    Attached Files Attached Files

  2. #2
    VBAX Tutor
    Joined
    Jun 2012
    Posts
    269
    Location
    Here is the source of the webpage...
    Attached Files Attached Files

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645

  4. #4
    VBAX Tutor
    Joined
    Jun 2012
    Posts
    269
    Location
    WebQuery will not work for me (I think...) as I need to programatically go through and import hundreds of files from different locations within the website.

    Regardless, I would much rather learn more about VBA by doing this with code.

    Ideally, I would like to find a way to identify the individual elements by some kind of loop and feedback... IE something like:
    for i = 1 to elements.count
    msgbox(element.id/name/whatever & vblf & i)
    next i

    That way I could loop through and find the element I am looking for easily, but I have not found any way to do that...

    I am at a bit of a loss and almost ready to give up on it though

    Help is greatly appreciated... especially the kind that helps me learn.

    Thanks,

    Josh / CodeNinja.

  5. #5
    It has always helped me.


  6. #6
    It has always helped me.


  7. #7
    VBAX Tutor
    Joined
    Jun 2012
    Posts
    269
    Location
    Thanks omnibuster... That looks like it could be of great help.

  8. #8
    VBAX Tutor
    Joined
    Jun 2012
    Posts
    269
    Location
    After a whole bunch of experimentation, I have figured out how to navigate to the reports I want. My code opens a new tab with the PDF format report just as I want it to.

    Now my challenge is to save the pdf report to a folder I designate. Any suggestions on the syntax to save a document?

    Thanks,

    Josh / CodeNinja.

Posting Permissions

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