Results 1 to 11 of 11

Thread: Downloading files from URL

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    98

    Downloading files from URL

    Hey guys,
    I decided the other day that i wanted to create a simple program that downloads files based on the users specifications. Now what i'm wondering is, what is the most simplest code you can think of that would allow me to download these files? Is this possible to create without having a million or so declarations or any API's?

    thanks for your help guys.

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Downloading files from URL

    The Inet control allows you to download files. I use it in a couple of my apps.

  3. #3
    Member garjanis's Avatar
    Join Date
    Jul 2007
    Posts
    42

    Re: Downloading files from URL

    Before long time ago i found this...
    Attached Files Attached Files
    Dim MyBrains As Boolean
    MyBrains.Enabled = False

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Downloading files from URL

    there is a very simple API urldownloadfile
    vb Code:
    1. Private Declare Function URLDownloadToFile Lib "urlmon" _
    2.    Alias "URLDownloadToFileA" _
    3.   (ByVal pCaller As Long, _
    4.    ByVal szURL As String, _
    5.    ByVal szFileName As String, _
    6.    ByVal dwReserved As Long, _
    7.    ByVal lpfnCB As Long) As Long
    8.  
    9. Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" _
    10.    Alias "DeleteUrlCacheEntryA" _
    11.   (ByVal lpszUrlName As String) As Long
    call it like
    vb Code:
    1. 'ensure this file does not exist in the cache
    2.    Call DeleteUrlCacheEntry(sSourceUrl)
    3.  
    4.  
    5.    If DownloadFile(sSourceUrl, sLocalFile) Then
    6. 'code for successful download
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Downloading files from URL


  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    98

    Re: Downloading files from URL

    Sorry guys, i didn't explain it properly. What i'm after is code that can do the same things such as those picture downloaders you can find on the net (Eg, type in a url and all the images/videos/what ever are downloaded from that site)
    It doesn't have to be advanced, just the basics will be the way to go. Ultimately i just want a program that can download files from the internet.
    So if i went to a random site and i typed in *.html, then all it would download would be the html page.

    Thanks for all the help.

  7. #7
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Downloading files from URL

    Check out my previous post. It shows the user how much of the file has downloaded using a progressbar.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    98

    Re: Downloading files from URL

    Thanks for that lintz, i'm don't have vb infront of me atm but, will that allow me to do what i want from my last post?

    Thanks again

  9. #9
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Downloading files from URL

    Glad to help

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    98

    Re: Downloading files from URL

    Lol, u didn't answer my question.
    Will that allow me to do what i asked in response #6?

    Thanks

  11. #11
    Junior Member
    Join Date
    Feb 2007
    Posts
    18

    Re: Downloading files from URL

    is it possible to download a file to a variable declare in VBA instead of a file in a drive?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width