Excel VBA videos | Excel VBA Part 49 - Downloading Files from Websites

Posted by Andrew Gould on 21 November 2016

Excel VBA doesn't have a native method for downloading files from websites but you can declare an API function that will enable you to do this. This video takes you through the process of declaring the API function and using it in your code, along with a bunch of other useful techniques such as using folder pickers, creating folders with FileSystemObjects and opening a Windows Explorer window using the Shell function.

You can download any files that you need to follow the video here.

You can increase the size of the video:

Full screen mode for YouTube

You can view the video in full screen mode as shown on the left, using the icon at the bottom right of the frame.

You can also increase the quality of the video:

Changing resolution

You can improve the resolution of the video using another icon at the bottom right of the frame. This will slow down the connection speed, but increase the display and sound quality. This icon only becomes visible when you start playing the video.

Finally, if nothing happens when you play the video, check that you're not using IE in compatibility view.

This page has 1 thread Add post
25 Nov 16 at 15:12

Kaspersky keeps blocking the file from being downloaded; the message I get says: HEUR: Trojan-Downloader.Script.Generic



25 Nov 16 at 22:26

Hi Joni,

Do you see this message for a specific file or for every file that it downloads?  If the former then I'd bet that it's a false-positive from Kaspersky. If you're concerned, however, please don't use the file. You can easily recreate the code simply by following along with the video.

Thanks for bringing it to our attention!

11 Apr 17 at 17:11

I have the same problem.

Kaspersky Internet Security said: The object is infected by HEUR:Trojan-Downloader.Script.Generic.

This only for this one file. Other files can be downloaded succesfully.

Andrew G  
11 Apr 17 at 21:31

It seems to be a Kaspersky specific issue - the HEUR indicates that a heuristic analysis has detected code in the file which matches a particular pattern of potentially malicious code. The file contains code which automatically downloads files from URLs which, as you can imagine, out of context could be construed as malicious. As I wrote the code I know that it's not and can only assume that Kaspersky is returning a false positive but, as I said in the previous response, if you're at all concerned by it, don't download it. You can easily recreate the code by simply following along with the video.

I hope that helps!