VBA Error while setting the permissions and/or timestamp

Advertisement

dodonohoe
Joined:
Posts:
1

VBA Error while setting the permissions and/or timestamp

Hi all,

I am getting the above error despite having selected the "ignore permissions errors on the console". The result is that of the ten folders I am trying to transfer it transfers one and then stops on the first file. I have read of command options using VB (Setting preserve time stamp option to false) and was wondering if there is something I can add to the code below (VBA) to prevent this error and allow my files/folders to be transferred.

Here is the full code I am using

Option Explicit

 
Sub VariableFTP()
 
    Dim mySession As New Session
    
    ' Enable custom error handling
        
    Upload mySession
    
    ' Query for errors
      
    
    If Err.Number <> 0 Then
        MsgBox "Error: " & Err.Description
 
        ' Clear the error
        Err.Clear
    End If
     
    ' Disconnect, clean up
    mySession.Dispose
     
    ' Restore default error handling
    On Error GoTo 0
    
End Sub
 
Private Sub Upload(ByRef mySession As Session)
 
    ''this is where we create a variable that allows our filepath _
    to change
  
    Dim FilePathx As String
    Dim FilePathY As String
    Dim FilePathz As String
    Dim FundName As String
    Dim Datex As String
    
    Sheets("Paperless Checklist ").Select
    
    FundName = Range("B6")
   
    
    
    Sheets("Variables").Select
    
     Datex = Range("B46")
    
    'FilePathx = Range("B22") & "\*"
    FilePathx = Range("B22") & "\"
    FilePathz = "/Usr/dubtrustee/"
    FilePathY = FilePathz & "/" & FundName & " " & Datex


      
    
    
    'FilePathx = Range("c2") & "\*"
    'FilePathY = Range("c4")
    
    ''check to see if the source filepath (filepathx)exists

    If Len(Dir(FilePathx, vbDirectory)) = 0 Then

    MsgBox "The Source File Path does not exist. Please check this file path.", vbCritical
    Exit Sub
    
    Else
    
    End If


    ''check to see if the source filepath (filepathx) actually contains files
    If Dir(FilePathx & "*.*") = "" Then
        MsgBox "The Source File Path does not contain any files. Please copy your client reports into this file path.", vbCritical
        Exit Sub

    Else
    

    
    Dim mySessionOptions As New SessionOptions
    With mySessionOptions
        .Protocol = Protocol_Sftp
        .HostName = "**********"
        .UserName = "******"
        .Password = "*********"
        .SshHostKeyFingerprint = "*************************************"
    End With

    
    ' Connect
    mySession.Open mySessionOptions
    
   
    
    ' Upload files
    Dim myTransferOptions As New TransferOptions
    myTransferOptions.TransferMode = TransferMode_Binary
     
    Dim transferResult As TransferOperationResult
    
    'we use this line if we want to take just the files not the folder
    'Set transferResult = mySession.PutFiles(FilePathx, "/Usr/sebprime/", False, myTransferOptions)
     Set transferResult = mySession.PutFiles(FilePathx, FilePathY, False, myTransferOptions)

    ' Throw on any error
    transferResult.Check
     
    
    MsgBox "Transfer Successful", vbInformation
    
    End If
    
End Sub

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: VBA Error while setting the permissions and/or timestamp

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Advertisement

You can post new topics in this forum