+ Reply to Thread
Results 1 to 5 of 5

file download from website

  1. #1
    Registered User
    Join Date
    12-23-2007
    Posts
    47

    file download from website

    I want to automate the download of files from a website using VB.
    The files are behind a securety screen and require the user to enter a password to enter. My thinking is that I could have a inputbox pop ask the user for the password and then VB would fill in the field that requires the password when required.

    Any suggestions?

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: file download from website

    One way would be to have a WebBrowser control and command button on a userform or sheet. The WebBrowser opens your site, you enter the password in the normal web page and navigate to the required page and then click the command button to download the file. The command button may have to parse the HTML DOM to find the file to download and then call URLDownloadToFile.

  3. #3
    Registered User
    Join Date
    12-23-2007
    Posts
    47

    Re: file download from website

    I know the name of each file, so I was thinking that I could create the hyperlinks and use VB to step through each hyperlink to activate the link but I need to know how to automatically fill in the password and the automatically click on the save file button

  4. #4
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: file download from website

    To input a password without showing what it is, use a textbox with the PasswordChar property set. You could then use a WebBrowser control or InternetExplorer object with HTML DOM manipulation/parsing (see HTMLDocument) to programmatically fill in the password on the web page, navigate to each link, find the save file button and click it (though this would probably bring up IE's normal download file open/save dialogue - that's why URLDownloadToFile might be better, if there's a URL for the file on the web page).

  5. #5
    Registered User
    Join Date
    12-23-2007
    Posts
    47

    Re: file download from website

    Okay, making some head way, I can down load the file from the website in this sample know. Next problem that I have is that the actual file that I need to get to is behind a password protected screen.

    Once I ask the user for the password, I need to populate the text field on IE with the password. How do I populate the text field and hit enter on the screen automatically?

    I think I some how need to reference the information in this line of code but not sure how?

    HTML Code: 
    PHP Code: 
    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

    Private Sub FileDownLoad()
       
    Dim test As Boolean
       Dim sSourceUrl 
    As String
       Dim sLocalFile 
    As String
       
       sSourceUrl 
    "http://www.solarfective.com/pdf/quoteform.pdf"
       
    sLocalFile "D:\Documents and Settings\414004425\Desktop\Sample.pdf"
       
       
    test URLDownloadToFile(0&, sSourceUrlsLocalFileBINDF_GETNEWESTVERSION0&) = ERROR_SUCCESS
       
    End Sub 

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1