there is a backup folder

Shell (sWinRarAppPath & " A -ep -df " & folderForMails & strName & ".rar " & strFolder) 

The variable strFolder contains the name of the folder with spaces. you need the shell to get the "folder name"

I try to do so, nothing happens, because closes the variable. As a result, in this place displays & strFolder &.

 Shell (sWinRarAppPath & " A -ep -df " & folderForMails & strName & ".rar " & """ & strFolder & """) 

    1 answer 1

    A good habit is to first assemble the command in a string variable, and then execute it (and Debug.Print for verification):

     strCommand = sWinRarAppPath & " A -ep -df " & folderForMails & strName & ".rar " & """" & strFolder & """" REM Debug.Print strCommand Shell strCommand 

    And quotes must be considered carefully.

    Better yet, instead of doubling, insert a quotation mark explicitly using CHR (34):

     strCommand = sWinRarAppPath & " A -ep -df " & folderForMails & strName & ".rar " & CHR(34) & strFolder & CHR(34) REM Debug.Print strCommand Shell strCommand 
    • Works. Special thanks for the advice, did not know how to check the assembled team. - Alexander Belyakov