Hack #99. Download Files Using the Web Browser Control

FTP files without ever leaving your database.

"Use a Browser Inside Access" [Hack #97] and "Pull the HTML Source Code from a Web Site" [Hack #98] show you how to browse the Web from an Access form and how to retrieve the source HTML code. This hack shows you how to use the Web Browser control to pull files from an FTP site.

The File Transfer Protocol (FTP) is commonly used to move files to and from a web server. Often, the site is password-protected, so to try out this hack, you need the rights to access an FTP site.

Placing the Web Browser Control on a Form

As discussed in "Use a Browser Inside Access" [Hack #97] , you can place the Microsoft Web Browser control on a form. The Navigate method takes a URL address to navigate to. In this hack, an FTP URL is supplied instead of an HTTP URL.

Using a line of code such as the following, the Web Browser control opens a login dialog (shown in Figure 10-9):

    Me.WebBrowser0.Navigate URL:="ftp.logicstory.com"
Entering a username and password for the FTP site

Figure 10-9. Entering a username and password for the FTP site

After the login is complete, the Web Browser control displays the site's contents. You can view, copy, delete, and rename objects depending on your user permissions, as shown in Figure 10-10.

Viewing contents of the web site

Figure 10-10. Viewing contents ...

Get Access Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.