Solved

Use ftp within VBA

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

739 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