VBA downloading secured file

ToastyStoemp

New Member
Joined
Aug 19, 2013
Messages
3
Hello fellow humans, and not humans

So I have been struggeling with this code for the last few days now, after reading all sort of possible sollutions, none seem to work.
And hereby I reachout for you people.

Here at work we register our hours on the website Myhours.com, However to make graphs and such about the productivity of each employee, we need to download the information of the site, till now we have been doing this manually, till I joined the club and have been working on automating the process.

The file on the sebserver can only be obtained after logging in to your myhours account. So far I've set up an IHTMLElement with an InternetExplorer running in the background loggin in the website and browsing to the desired place. So it opens the CSV file in the browser window, and thats where I'm stuck, I cannot figure out how to either rip it from the browser view, or download it and import it. Help would be much apreciated.

May I excuse myself for my bad English, its not my first nor second tongue

Code:
Dim HTMLDoc As HTMLDocument    Dim oBrowser As InternetExplorer
    Dim oHTML_Element As IHTMLElement
    Dim sURL As String


    On Error GoTo Err_Clear  'als er een error gebeurt ga naar de error behandeling
    sURL = "http://www.myhours.com/default.asp"  'instellen van de URL
    Set oBrowser = New InternetExplorer 'Opstellen van de browser
    oBrowser.Silent = True
    oBrowser.timeout = 60 'stel timeout in
    oBrowser.navigate sURL 'ga naar de url
    oBrowser.Visible = True 'Browser in de achtergrond (onzichtbaar) laten lopen


    Do
    Loop Until oBrowser.readyState = READYSTATE_COMPLETE 'Wachten tot de browser geladen is


    Set HTMLDoc = oBrowser.document 'De webpagina tijdelijk opslaan, zodat kan worden gekeken waar de login en wachtwoord box staan


    HTMLDoc.all.Email.Value = mail 'invullen van het e-mail adress op de myHours website
    HTMLDoc.all.Password.Value = wachtwoord 'invullen van het wachtwoord op de myHours website
    
    


    For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") 'zoeken naar de "submit" knop
    If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For 'het activeren van de "submit" knop
    Next
    
    Application.StatusBar = "De myHours gegevens opvragen, kan even duren..." 'De status baar message updaten
    sURL = "http://www.myhours.com/myAccount/reports_timesheet1_csv.asp?period=&dateL=1%2F01%2F" & Me.listJaar.Value & "&dateH=31%2F12%2F" & Me.listJaar.Value & "&fieldsClient=True&fieldsDuration=True&fieldsTask=True&fieldsIn=True&fieldsOut=True&fieldsNote=True&alerts_color=True"
    oBrowser.navigate sURL 'Browsen naar de pagina waar de uren worden weer gegeven
             
    Do
    Loop Until oBrowser.readyState = READYSTATE_COMPLETE 'Wachten tot de browser geladen is

ToastyStoemp
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,223,956
Messages
6,175,609
Members
452,660
Latest member
Zatman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top