Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default auto download file everyday

Hi all,

can somebody stear me in the right direction.

I would like to download this file
http://nus800:8060/resources/thors/cni/CNI_Tool.xls into this folder
g:\everyone\thorsreports\ and schedule it to run automatically each
day, eg 9am with opening excel?

The file would replace the existing file each day, so that it's "up to
date"...

Can this be done with VBA?

Excel 97 WinNT, always online


TIA and cheers
steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default auto download file everyday

Steve



I found this code sometime ago and I use it almost daily to download
text file & a csv file






' Copyright ©1996-2003 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000


Sub AutoDownloadIntranetFile()
Dim sSourceUrl As String


sSourceUrl = "http://nus800:8060/resources/thors/cni/CNI_Tool.xls"
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
sSavedInetFile$ = "g:\everyone\thorsreports\CNI_Tool.xls"
If Dir(sSavedInetFile) < "" Then
Kill sSavedInetFile
End If
If DownloadFile(sSourceUrl, sSavedInetFile) = False Then
MsgBox "Error In Downloading File" _
& Chr(10) _
& "Cannot Continue", vbCritic
End
End If
On Error GoTo 0
End Sub


Public Function DownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean

'Download the file. BINDF_GETNEWESTVERSION forces
'the API to download from the specified source.
'Passing 0& as dwReserved causes the locally-cached
'copy to be downloaded, if available. If the API
'returns ERROR_SUCCESS (0), DownloadFile returns True.
DownloadFile = URLDownloadToFile(0&, _
sSourceUrl, sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function

Note Displayed Winking Face = close bracke

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default auto download file everyday

perfecto
cheers


On Wed, 28 Jul 2004 23:01:29 -0500, mudraker
wrote:

Steve



I found this code sometime ago and I use it almost daily to download a
text file & a csv file






' Copyright ©1996-2003 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000


Sub AutoDownloadIntranetFile()
Dim sSourceUrl As String


sSourceUrl = "http://nus800:8060/resources/thors/cni/CNI_Tool.xls"
''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''
sSavedInetFile$ = "g:\everyone\thorsreports\CNI_Tool.xls"
If Dir(sSavedInetFile) < "" Then
Kill sSavedInetFile
End If
If DownloadFile(sSourceUrl, sSavedInetFile) = False Then
MsgBox "Error In Downloading File" _
& Chr(10) _
& "Cannot Continue", vbCritic
End
End If
On Error GoTo 0
End Sub


Public Function DownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean

'Download the file. BINDF_GETNEWESTVERSION forces
'the API to download from the specified source.
'Passing 0& as dwReserved causes the locally-cached
'copy to be downloaded, if available. If the API
'returns ERROR_SUCCESS (0), DownloadFile returns True.
DownloadFile = URLDownloadToFile(0&, _
sSourceUrl, sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function

Note Displayed Winking Face = close bracket


---
Message posted from http://www.ExcelForum.com/


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
download file of 200 name, addr.etc to excel file - how? please ad Tony V. Excel Worksheet Functions 1 October 24th 08 09:50 AM
any auto formula changing 1 - 31st everyday & multiply $975 Kelly Lim Excel Discussion (Misc queries) 15 July 31st 06 08:06 AM
HELP----Can't get a CSV file to download onto my PC Bubey New Users to Excel 2 June 8th 06 02:42 AM
Auto download spreadsheet claytorm Excel Discussion (Misc queries) 0 August 25th 05 07:07 PM
I need to download an exel spreadsheet file. (file extension :xls) buckrogers Excel Discussion (Misc queries) 2 December 8th 04 11:08 PM


All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"