Solved

Use ftp within VBA

Posted on 2004-04-14
5
2,339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

691 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