Solved

Use ftp within VBA

Posted on 2004-04-14
5
2,327 Views
Last Modified: 2009-01-29
Hi:
I am attempting to do ftp operation within my VBA so that I could download files from the unix side.  I read from several posts which recommend using the control "inet".  My questions are:
- what is "inet" control ?
- where can I find it ?
- how do I put the "inet" control into my form ?  
- sometimes it is called "inet", other times it is called "inet1".  Which is right ?

Thanks
0
Comment
Question by:AugustineWan
5 Comments
 
LVL 7

Accepted Solution

by:
ramesh12 earned 100 total points
ID: 10829762
I am not sure if this helps you but you can use shell to do ftp like this

                Dim cmdline As String
                cmdline = "ftp  -s:somefile.txt"
                Shell cmdline, vbhide

Your somefile.txt will be like this

PROMPT
OPEN yoururl
username
password
QUOTE SITE FILETYPE=JES
LCD Yourlocaldirectorypath
GET/Put yourfilename
BYE
0
 

Author Comment

by:AugustineWan
ID: 10829849
Thanks for replying.  I am not in the office now but I will try the code once I get in the office tomorrow.  It is 11:45 pm local time.  
So, does it mean that it is not necessary to use the "inet" control to do the ftp ?
0
 
LVL 7

Assisted Solution

by:manthanein
manthanein earned 50 total points
ID: 10829857
- what is "inet" control ?

Microsoft Windows Internet Transfer

- where can I find it ?

C:\Windows\System32\Msinet.ocx

- how do I put the "inet" control into my form ?
right click on the Control Toolbox click on Additional controls,  check "Microsoft Windows Internet Transfer" ,  and it will appear on your toolbox
0
 
LVL 7

Expert Comment

by:ramesh12
ID: 10830173
You dont need to use any control, just place code where ever you want to execute from and then create a text file with your ftp server info.

0
 
LVL 9

Expert Comment

by:tkalchev
ID: 10831825
Private Declare Function URLDownloadToFile Lib "urlmon" _
   Alias "URLDownloadToFileA" _
  (ByVal pCaller As Long, _
   ByVal szURL As String, _
   ByVal szFileName As String, _
   ByVal dwReserved As Long, _
   ByVal lpfnCB As Long) As Long
   
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000


Public Function DownloadFile(sSourceUrl As String, _
                             sLocalFile As String) As Boolean
 
   DownloadFile = URLDownloadToFile(0&, _
                                    sSourceUrl, _
                                    sLocalFile, _
                                    BINDF_GETNEWESTVERSION, _
                                    0&) = ERROR_SUCCESS
   
End Function

Then simply call DownloadFile :

bResult = DownloadFile ( "ftp://ftp.site.com/path/file.ext", "c:\temp\file.ext" );

If you need to login on the ftp server with username and password, then modify the call like this :

bResult = DownloadFile ( "ftp://USERNAME:PASSWORD@ftp.site.com/path/file.ext", "c:\temp\file.ext" );
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now