[AccessD] I ask Bard to write an FTP upload module

Stuart McLachlan stuart at lexacorp.com.pg
Tue Apr 25 15:48:12 CDT 2023


I'm almost certain there is no such thing as a  FSO FTP object.  That;s what you get when AI 
engines scrape the intertubes and catch all the garbae code that has been posted over the 
years. 


On 25 Apr 2023 at 8:26, Rocky Smolin wrote:

> I got a popup in Edge - Bear is ready to write code for me.  So I
> thought I'd give it a try with the FTP Upload program I'm trying to
> write. Said "write a module in VBA to FTP a file to a server"
> 
> Below is the original code and my modifications to pick up the
> arguments from a table.
> 
> It errors out on the line  Set oFTP = CreateObject("FSO.Ftp") 429 -
> ActiveX component cannot create object.
> 
> The code looks pretty simple, straightforward. Is there a simple,
> straightforward fix for this?
> 
> MTIA
> 
> Rocky
> 
> 
> Here's the code that Bard created:
> 
> ' Original Code
> 'Declare variables
> 'Dim oFSO As Object
> 'Dim oFTP As Object
> 'Dim strServer As String
> 'Dim strUserName As String
> 'Dim strPassword As String
> 'Dim strLocalFile As String
> 'Dim strRemoteFile As String
> 
> 'Set variables
> 'strServer = "myserver.example.com"
> 'strUserName = "username"
> 'strPassword = "password"
> 'strLocalFile = "C:\Users\YourUserName\Desktop\myfile.txt"
> 'strRemoteFile = "/myfolder/myfile.txt"
> 
> 'Create an instance of the FileSystemObject
> 'Set oFSO = CreateObject("Scripting.FileSystemObject")
> 
> 'Create an instance of the FTP object
> 'Set oFTP = CreateObject("FSO.Ftp")
> 
> 'Open a connection to the FTP server
> 'oFTP.Open strServer, strUserName, strPassword
> 
> 'Upload the file
> 'oFTP.PutFile strLocalFile, strRemoteFile
> 
> 'Close the connection
> 'oFTP.Close
> 
> And here's the code I modified to pick up the arguments from a table:
> 
> 'Dim oFSO As Object
> 'Dim oFTP As Object
> 'Dim strServer As String
> 'Dim strUserName As String
> 'Dim strPassword As String
> 'Dim strLocalFile As String
> 'Dim strRemoteFile As String
> 
> 'Set variables
> 'strServer = Me.fldHost
> 'strUserName = Me.fldUser
> 'strPassword = Me.fldPassword
> 'strLocalFile = Me.fldFileToUpload
> 'strRemoteFile = Me.fldDestinationDirectory &
> Me.fldDestinationFileName
> 
> 'Create an instance of the FileSystemObject
> 'Set oFSO = CreateObject("Scripting.FileSystemObject") '
> 
> 'Create an instance of the FTP object
> 'Set oFTP = CreateObject("FSO.Ftp")
> 
> 'Open a connection to the FTP server
> 'oFSO.Open strServer, strUserName, strPassword
> 
> 'Upload the file
> 'oFTP.PutFile strLocalFile, strRemoteFile
> 
> 'Close the connection
> 'oFTP.Close
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list