[AccessD] I ask Bard to write an FTP upload module
Arthur Fuller
fuller.artful at gmail.com
Tue Apr 25 10:35:35 CDT 2023
Look at the upside. There is still a need for us carbon units.
On Tue., Apr. 25, 2023, 11:27 a.m. Rocky Smolin, <rockysmolin2 at gmail.com>
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