Article ID: 163653
Article Last Modified on 1/19/2007
Form: frmOpenURL
--------------------------
Caption: OpenURL Form
Command button:
Name: cmdWriteFile
Caption: Write to Disk
Command button:
Name: cmdGetHeader
Caption: Get Header
Dim objInet as Inet
Private Sub Form_Load()
' Set a reference to the internet transfer control.
Set objInet = Me!axInetTran.Object
End Sub
Private Sub cmdWriteFile_Click()
Dim b() as Byte
' Set the internet transfer control protocol and URL.
objInet.Protocol = icHTTP
objInet.URL = "HTTP://www.microsoft.com"
' Retrieve the HTML data into a byte array.
b() = objInet.OpenURL(objInet.URL,icByteArray)
' Create a local file from the retrieved data.
Open "C:\Homepage.htm" For Binary Access Write As #1
Put #1, , b()
Close #1
MsgBox "Done"
End Sub
Private Sub cmdGetHeader_Click()
' Set the internet transfer control protocol and URL.
objInet.Protocol = icHTTP
objInet.URL = "HTTP://www.microsoft.com"
' Open the HTML and display the header information.
objInet.openURL objInet.URL, icByteArray
MsgBox objInet.GetHeader
End Sub
Form: frmRetrieveFile
--------------------------
Caption: Retrieve FTP File
Command button:
Name: cmdGetFile
Caption: Get FTP File
Text box:
Name: txtFTPSite
Text box:
Name: txtFileName
Dim objFTP as Inet
Private Sub Form_Load()
' Set a reference to the internet transfer control.
Set objFTP = Me!axFTP.Object
End Sub
Private Sub cmdGetFile_Click()
Dim strSite As String
Dim strFile As String
strSite = Me!txtFTPSite
strFile = Me!txtFileName
objFTP.Protocol = icFTP
objFTP.URL = strSite
objFTP.Execute strSite, "Get " & strFile & " C:\" & strFile
End Sub
Private Sub axFTP_StateChanged(ByVal State As Integer)
' Display a message when the transfer is finished.
If State = 12 Then Msgbox "File Transferred"
End Sub
Additional query words: ole custom
Keywords: kbhowto kbprogramming kbusage KB163653