Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

copy a file to an ftp site in visual basic

14 views
Skip to first unread message

Tino

unread,
Jun 18, 2001, 9:22:57 PM6/18/01
to
I want to use a macro to copy a file from my local Windows 98 based PC to
our Unix box.

If anyone can offer any advice on how to do this, it would be much
appreciated.

Thanks,

Tino


Vasant Nanavati

unread,
Jun 18, 2001, 10:24:22 PM6/18/01
to
Look at the FileCopy statement in online help.

"Tino" <tana...@ingram.com.au> wrote in message
news:mh9mg9...@firewall.ingram.com.au...

Jeff McAhren

unread,
Jun 18, 2001, 11:04:11 PM6/18/01
to
FileCopy to a Unix box? That would be impressive.

If you can't get that to work, take a look at the following sites.

This MSDN article is from 1996, but I know someone who used this solution in
VB6, so I assume it will work in VBA.
http://msdn.microsoft.com/library/default.asp?URL=/library/techart/msdn_advf
tp.htm

This is a rather involved solution, but it is a solution. From an MVP page:
http://www.mvps.org/vbnet/index.html?code/network/ftplist.htm

Alternatively, there are a bunch of ActiveX controls available out there
that would simplify the task.


"Vasant Nanavati" <vas...@aol.com> wrote in message
news:#d4m1bG#AHA.1256@tkmsftngp05...

Jeff McAhren

unread,
Jun 18, 2001, 11:08:28 PM6/18/01
to
Ooops, wrong link on the MSDN site. That was a C++ solution. This is the
correct link:

http://msdn.microsoft.com/downloads/samples/Internet/networking/vbftpjr/samp
le.asp


"Jeff McAhren" <mca...@hotmail.com> wrote in message
news:ecKF0vG#AHA.1444@tkmsftngp05...

Jeff McAhren

unread,
Jun 18, 2001, 11:16:23 PM6/18/01
to
I'm embarrassed to say that I'm a premature poster. The solution clearly
states that Visual Studio SP2 is required, "because it uses the updated
comctl32.ocx".

HOWEVER, I am using my home machine at this moment, which has never seen
Visual Studio, and yet I DO have the file, comctl32.ocx. WinME, IE5.5,
Office 2000 Pro.


"Jeff McAhren" <mca...@hotmail.com> wrote in message

news:Oj8KNyG#AHA.236@tkmsftngp04...

Alan B. Pearce

unread,
Jun 19, 2001, 5:32:16 AM6/19/01
to
>FileCopy to a Unix box? That would be impressive.

>If you can't get that to work, take a look at the following sites.

Probably work very easily if Samba is set up on the Unix box.


Dave Peterson

unread,
Jun 19, 2001, 5:21:18 PM6/19/01
to
I use MS's FTP that comes with windows and do this:

Behind a user form that collects userid and password:
====================================================

Private Function do_ftp(strFile As String) As Boolean

myuserid = Trim(TextBox2.Text)
mypassword = Trim(TextBox3.Text)

On Error GoTo do_ftpError

intFileNum = FreeFile()
Close #intFileNum
Open myftptxt_file For Output As #intFileNum

'Create the FTP Command File.
Print #intFileNum, "open xxxxxxx"
Print #intFileNum, myuserid
Print #intFileNum, mypassword
Print #intFileNum, "put " & work_directory & strFile
Print #intFileNum, "bye"
Close #intFileNum

'Execute the FTP Commands to upload the file.
ShellAndWait "ftp.exe -v -s:" & work_directory & "myftp.txt",
vbMinimizedNoFocus

'Delete both temporary files.
Kill myftptxt_file
Kill work_directory & strFile

do_ftp = True
Application.StatusBar = False

Exit Function

do_ftpError:
Close #intFileNum
MsgBox "FTP Failed: The VB Error Was As Follows:" & _
Chr(13) & Error(Err), vbCritical
do_ftp = False

End Function

Myftptxt_file holds the ftp commands and myftp.txt holds the ASCII (for me) data
I want transfered. (I actually use this to go from the PC to mainframe.)

And I use ShellandWait to wait for the ftp to finish:

Standard Module:
================
Option Explicit

Private Const PROCESS_QUERY_INFORMATION As Long = &H400
Private Const STILL_ACTIVE As Long = &H103

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As
Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As
Long, lpExitCode As Long) As Long


''' Arguments: szCommandLine The command line to execute using Shell.
''' iWindowState (Optional) The window state parameter to pass
''' to the Shell function. Default = vbHide.
''' See Shell function help for other options.
Sub ShellAndWait(ByVal szCommandLine As String, Optional ByVal iWindowState As
Integer = vbHide)

Dim lTaskID As Long
Dim lProcess As Long
Dim lExitCode As Long
Dim lResult As Long

''' Run the Shell function.
lTaskID = Shell(szCommandLine, iWindowState)

''' Get the process handle from the task ID returned by Shell.
lProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 0&, lTaskID)

''' Loop while the shelled process is still running.
Do
''' lExitCode will be set to STILL_ACTIVE as long as the shelled process
is running.
lResult = GetExitCodeProcess(lProcess, lExitCode)
DoEvents
Loop While lExitCode = STILL_ACTIVE

End Sub

--

Dave Peterson
ec3...@msn.com

Jeff McAhren

unread,
Jun 20, 2001, 6:30:47 PM6/20/01
to
Beautimus! This one goes in the archive.

--
Jeff McAhren
Dallas, Texas


"Dave Peterson" <ec3...@msn.com> wrote in message
news:3B2FC24E...@msn.com...

Dave Peterson

unread,
Jun 20, 2001, 7:15:32 PM6/20/01
to
That's where I got it, too.

--

Dave Peterson
ec3...@msn.com

0 new messages