Solved

Use ftp within VBA

Posted on 2004-04-14
5
2,336 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

830 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