Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 10-20-2013, 10:02 AM
Catalin.B Catalin.B is offline Macro to login to horseracebase.com web site and download today cards file Windows Vista Macro to login to horseracebase.com web site and download today cards file Office 2010 32bit
Expert
Macro to login to horseracebase.com web site and download today cards file
 
Join Date: May 2011
Location: Iaşi, România
Posts: 386
Catalin.B is on a distinguished road
Default

Well, after some attempts, still no valid file.
The code: (in 2 versions)
Code:
Sub DownloadFile()

Dim myURL As String
myURL = "http://horseracebase.com/excellcards.php"

Dim WinHttpReq As Object


Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "POST", myURL, False, ".........", "........."
WinHttpReq.Send

myURL = WinHttpReq.responseBody
If WinHttpReq.Status = 200 Then
    Set oStream = CreateObject("ADODB.Stream")
    oStream.Open
    oStream.Type = 1
    oStream.Write WinHttpReq.responseBody
    oStream.SaveToFile ThisWorkbook.Path & "\cards " & Format(Time, "hh-mm") & ".xls", 2
    oStream.Close
End If

End Sub
Sub DownloadFile2()

Dim myURL As String
myURL = "http://horseracebase.com/excellcards.php"

Dim req As Object
Dim user As String, pass As String
user = "........."
pass = "........."
credentials = "username=" & user & "&password=" & pass



Set req = CreateObject("WinHttp.WinHttpRequest.5.1")
req.SetAutoLogonPolicy 0

req.Open "POST", myURL, False
req.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
req.Send credentials

myURL = req.responseBody
If req.Status = 200 Then
    Set oStream = CreateObject("ADODB.Stream")
    oStream.Open
    oStream.Type = 1
    oStream.Write req.responseBody
    oStream.SaveToFile "E:\cards.xls", 2 ' 1 = no overwrite, 2 = overwrite
    oStream.Close
End If

End Sub
Both codes downloads the file but the problem is that the code is not actually logging in, the cards file downloaded has this message inside:
" <p class=standard>You must hold a valid <a href='index.php'>HorseRaceBase</a> membership to access this feature. <a href='subscribe.php'>Sign up for a free trial now</a></p>

Can you point to the source of this error? I have to say i could not found the error, i used Fiddler to analyze browsing session, no result...
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a SharePoint site macro Fredrik Misc 0 10-25-2012 12:49 AM
Pop-up requesting me to download a file when Gillonline Outlook 0 04-18-2012 01:33 AM
Outlook forces file download to browser Choja Outlook 0 11-17-2010 01:19 AM
Macro to download FTP File HowardC Excel 0 05-31-2010 11:16 AM
Macro to login to horseracebase.com web site and download today cards file Trying to download a .doc file from email or website on word 2007 on vista wilson723 Word 1 10-23-2009 11:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft