excelaudio
New Member
- Joined
- Nov 4, 2015
- Messages
- 8
So I have spent WAY too much time trying to get to this answer. Below is what I need to get at...and yes, I have been to RondeBruin's site and it hasn't helped much from my limited knowledge.
I have Excel 2010, WinZip16.0 (winzip64.exe), Internet Explorer 11
Below is what I have so far:
I have Excel 2010, WinZip16.0 (winzip64.exe), Internet Explorer 11
- Download .zip file from site (I got this working)
- Rename downloaded file to something more simple in the same folder it was downloaded to
- If I go to download the file and it already exists, replace it with the file I'm downloading & renaming today
- auto extract zip file to the same folder it was downloaded to
- auto open .xls file that was just extracted
Below is what I have so far:
Code:
Option Explicit
Private Declare Function URLDownloadToFileA Lib "urlmon" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Public Sub Step2_Download_Unzip_Daily_KMI()
Dim spath As String, sFileName As String, PrevBusDayFile As String
Dim TodayFile As Variant
Dim DownloadLocale As String
Dim FileMonth As String
Dim FileYear As String
Dim FileDate As String
Dim ZipFilename As Variant
FileMonth = Format(Date, "MM-MMM")
FileYear = Format(Date, "yyyy")
spath = "http://.................." & FileYear & "/" & FileMonth & "/"
sFileName = Format(Date, "yy-mmdd") & "%20DAILY%20KMI%20AG%20Data.zip"
TodayFile = DownloadLocale & sFileName
DownloadLocale = "C:\Users\username\Desktop\Import\ZIP\"
DownloadFile spath & sFileName, DownloadLocale & sFileName
End Sub
Private Function DownloadFile(URL As Variant, sFileName As String) As Boolean
'Thanks Mentalis:)
Dim lngRetVal As Long
lngRetVal = URLDownloadToFileA(0, URL, sFileName, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function