Download Files from Internet Explorer

rprosser

New Member
Joined
Sep 28, 2006
Messages
10
Hi,

I have macro setup to login to a website and perform a WebQuery. There are several links that the query downloads and puts on the spreadsheet as hyperlink and users will work from this sheet using the hyperlink to get data.

One of these links is used to navigate out to see if there are any attachments the client may have uploaded for us to download. There could be 1 or a number of files to download and 9 out 10 times there is at least 1 file to download which forces us to put a fulltime employee on this. Since I have created several macros to automate daily task I have been asked to explore the possibility of automating this process.

I’m very familiar with VBA, but I’m not familiar with using it to communicate with internet explorer. With that said, below is the source code of the files that need downloaded and I was wondering if someone who is familiar with this can take a look at it and give me some code which allow me to do the following:

1. Determine the number of files that need downloaded.
2. Download the file to a directory on my computer.

If you need clarification on anything or need additional information, please let me know.


Also, does anyone know if a book or a good resource online that will help me learn how to use VBA to communicate to internet explorer?


Rick
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Rick

If you search the board you will find code to download files using VBA and IE.

By the way it's not really VBA you should be looking at, it's the DHTML object model.

PS Can you edit your post, something seems to have went wrong.
 
Upvote 0
I fixed your post; if you want to post code, use the code tags. If you need to open a file found on the internet, you can use the workbook.open method and just supply it's path.
 
Upvote 0
Almost have it working

Hi again,

I have couple of other questions that I’m hoping you may be able to answer. I have found some code and modified it so it downloads files from the internet, but the problem I keep having is I’m using the “Click” on the link which opens a dialog box to open, save or cancel. I’m currently using send keys to click the “Save” button and then the save box comes up and I’m using the send keys once again to enter the file name and click ok, but would rather not do that if there is something else available.. A tidbit of info I left out before, all the files I’m downloading are PDF files, and the goal is to save them to a directory, not open. I tried the Workbook open, but that didn’t work and I guess it probably has something to do with the PDF file.

Here are my questions:

1. I provided the source code below as well as the code I have working as descried above and was wondering if you know of a better way to download these PDF.
2. Is there a programmable way to control the “Download” and the “File Save As” dialog?
3. Of course any suggestions from you professional are greatly appreciated.



Again, with me just venturing in IE and VBA, I’m a little lost. Thanks for your patience and time.

Thanks,

Rick


Dim ie As Object
Dim i As Long
Set ie = CreateObject("InternetExplorer.Application")
With ie
Range("Y21").Select
GetHyp = Selection.Hyperlinks(1).Name
.Visible = True 'Just for our test
.Navigate GetHyp
Do While .ReadyState <> 4: DoEvents: Loop
Do While .Busy: DoEvents: Loop

With .Document
For i = 0 To .links.Length - 1
If InStrB(1, .links(i).innerText, "APPRAISAL IMAGE") Then

.links(i).Click

‘Wait for save, open or cancel box to appear
Application.Wait (Now + TimeValue("0:00:15"))

‘navigate to save button.
For s = 1 To 3
Application.SendKeys "{TAB}", True
Next s

Application.SendKeys "~"

“Enter file name

Application.Wait (Now + TimeValue("0:00:5"))
Application.SendKeys "File Name"
Next i
End With

End with



Rich (BB code):
td valign="top"><table cellSpacing='0' cellPadding='0' border='0'>		<tr>			<td class='TDColorPrimary' width='100%'>
		
		
	


	
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">OADI XML Appraisal</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">APPRAISAL IMAGE</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">APPRAISAL REPORT</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">OADI XML Appraisal</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">APPRAISAL IMAGE</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">APPRAISAL REPORT</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">OADI XML Appraisal</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">APPRAISAL IMAGE</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">APPRAISAL REPORT</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">OADI XML Appraisal</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">APPRAISAL IMAGE</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">APPRAISAL REPORT</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle">OADI XML Appraisal</td> </tr> <tr> <td valign="top"><table cellSpacing='0' cellPadding='0' border='0'> <tr> <td class='TDColorPrimary' width='100%'>
assocfiles.gif
</td> </tr> </table></td> <td valign="top"> </td> <td valign="middle"><a class="BodyLink" id="6e5ae050-b37e-4606-b43b-5c99ab171b06" href="javascript:
Rich (BB code):
 
Upvote 0
Rick

Have you searched the forum?

I know there's threads out there that deal with this.

By the way the post hasn't come out well again, what is it your actually trying to show.
 
Upvote 0
Rick

I just did a board search and found this thread.

I didn't thoroughly read it, and it might not quite be what you want but I think it's probably worth a read.
 
Upvote 0
Boy, you sure do respond quickly, thanks so much.

What I’m trying to show you in the source code are the PDF file links. I figured the person answering my question would like to see what I was trying to describe.

As far as my post goes, do you have any recommendations for me? I thought it came out pretty good this time.

Thanks for the link, I'll look at it now. I truly appreciate the help!

Rick
 
Upvote 0
Rick

All most (all?) people will see a jumble of HTML code, which is hard enough to interpret at the best of times.:eek:

This type of thing can be difficult to help with especially without a URL to play with, and since the site you're dealing with is secure that's obviously a problem.
 
Upvote 0

Forum statistics

Threads
1,213,514
Messages
6,114,078
Members
448,547
Latest member
arndtea

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top