Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default File Saving macro ?!?!


Hi All,

want to make a simple macro here. I have a list of cells what each has
a weblink to a file. I want to make a Macro that will download each
linked file into a directory on my PC. is this possible

simple execution:
active cell will start at "A1", there will be a web-link as the value
for the cell and i want the file for the web-link saved directly to a
directory on my c-drive. it will work it's way down until the
activecell is empty.


Regards
Hemant


--
hemants
------------------------------------------------------------------------
hemants's Profile: http://www.excelforum.com/member.php...o&userid=15031
View this thread: http://www.excelforum.com/showthread...hreadid=574423

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default File Saving macro ?!?!


Hement

This is some code I found on the net ages ago with some additional bits
to loop you through column A.

You will need to set correct parramaters for the sLocalFile variable.
This is the full path and file name for where the downloaded file is to
be saved to



Option Explicit


'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' 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(Optional bReportOnly As Boolean)
Dim sSourceUrl As String
Dim sDate As String

Dim i4Row As Integer
Dim iLastRow As Integer

iLastRow = Cells(Rows.Count, "a").End(xlUp).Row
For i4Row = 1 To iLastRow Step -1
sSourceUrl = Cells(i4Row, "a")
sLocalFile = Cells(i4Row, "b")

If Dir(sLocalFile) < "" Then
Kill sLocalFile
End If
If DownloadFile(sSourceUrl, sLocalFile) = False Then
MsgBox "Error In Downloading File" _
& Chr(10) _
& "Cannot Continue", vbCritical
End
End If
Next i4Row
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


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=574423

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
Saving a text file macro jknapp1005 Excel Discussion (Misc queries) 2 September 5th 06 08:01 PM
Macro Help for Saving a file [email protected] Excel Worksheet Functions 3 May 12th 06 05:16 PM
Saving a file via a Macro? Jim Rech Excel Programming 0 June 23rd 04 07:39 PM
Saving a file in a macro Eric Dreshfield Excel Programming 2 September 10th 03 04:49 PM
Saving a new file with a macro Mike[_36_] Excel Programming 0 July 23rd 03 03:55 PM


All times are GMT +1. The time now is 11:05 PM.

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

About Us

"It's about Microsoft Excel"