Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overview on the Inet control

Status
Not open for further replies.

TLiberty

Programmer
Nov 22, 1999
27
US
I have a present project to download files from a website to my server. can anyone give me a simple code on how to do this using the INet control.<br>
<br>
thanks.
 
TLiberty,<br>
<br>
Here is some code that I came up with after wrestling with this one for a while myself. This code is actually getting the filenames from an array, but you can change it any way you like to meet your needs. Let me know if you have any questions or problems. Hope it helps. :)<br>
<br>
'=============================<br>
' CODE<br>
'=============================<br>
Private Sub GetFiles()<br>
On Error GoTo errGetFiles<br>
Dim x() As Byte, i As Integer<br>
<br>
For i = 0 To UBound(aFileNames)<br>
Inet1.URL = &quot;<A HREF=" TARGET="_new"> & aFileNames(i)<br>
x = Inet1.OpenURL(, icByteArray)<br>
Open &quot;C:\&quot; & aFileNames(i) For Binary Access Write As #1<br>
Put #1, , x()<br>
Close #1<br>
Next i<br>
<br>
exitGetFiles:<br>
Exit Sub<br>
<br>
errGetFiles:<br>
Err.Raise 805, , &quot;Error getting files from server&quot;<br>
<br>
End Sub
 
Thanks a million Kcronin<br>
<br>
One more question, can I use this same routine to download and open a text file.
 
Slightly off topic but... Kcronin - Did you happen to be the lead singer for REO Speedwagon? I bet you've heard that a 1000 times now huh? Opps, I mean 1000 and 1. <p>Steve Meier<br><a href=mailto:sdmeier@jcn1.com>sdmeier@jcn1.com</a><br><a href= > </a><br>
 
TLiberty,<br>
<br>
Well, in the code, you can specify the exact path of the file you downloaded. If you know the file type, such as Word, and already know the file path, then you can create an instance of Word and open your document in it.<br>
<br>
Hope this helps. <p>Kenneth W. Cronin, MCP<br><a href=mailto:kcronin@atdsystems.com>kcronin@atdsystems.com</a><br><a href= Systems Corporation</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top