Hi,

Each month I have to download a document and unzip it. I have been trying to automate this process. The file is always named "MonthYYYY.zip" March2013.zip for example. This code attempts to use an InputBox to download the file based on the name I type in. It downloads an empty zip file:

Sub getdata()

Dim reportdate1 As String
reportdate1 = InputBox("Enter the full month name and the year with no spaces for which you need the report in the space below.    Ex) March2013, January2011")

Dim myURL As String
'This macro downloads files from the URL below with the file extension based on the inputbox variable name
myURL = "http://portal.hud.gov/hudportal/documents/huddoc?id=" & reportdate1 & ".zip"

        Dim WinHttpReq As Object
        Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
        WinHttpReq.Open "GET", myURL, False
        WinHttpReq.Send

        myURL = WinHttpReq.ResponseBody
        Set oStream = CreateObject("ADODB.Stream")
        oStream.Open
        oStream.Type = 1
        oStream.Write WinHttpReq.ResponseBody
        'The path below is your save destination
        oStream.SaveToFile ("C:\Documents and Settings\user\Desktop\Zip Files\" & reportdate1 & ".zip")
        oStream.Close

Application.ScreenUpdating = True
End Sub
That is the actual URL. It usually makes me wait while it scans the file. Is there a way around this? I've had this exact code work for sites where there is no scanner. Please help if you can. Thanks!

DAK