miércoles, 22 de mayo de 2013

COMO DESCARGAR UN ARCHIVO A UNA CARPETA DESDE UNA URL DEFINIDA

Option Explicit 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 Dim Ret As Long Sub Sample() Dim strURL As String'almacena link Dim strPath As String'almacena direccion donde va a guardar strURL = "http://www.superfinanciera.gov.co/Cifras/informacion/diarios/tcrm/historia.xls" strPath = "D:\Mis documentos\Historico TRM\myfilename.xls"'importante al pegar la ruta debe poner el nombre del archivo como va quedar guardado junto con la extension Ret = URLDownloadToFile(0, strURL, strPath, 0, 0)'realizar descarga If Ret = 0 Then MsgBox "File successfully downloaded" Else MsgBox "Unable to download the file" End If End Sub