Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Use ftp within VBA

Posted on 2004-04-14
5
Medium Priority
?
2,344 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 400 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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Suggested Courses

636 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