Excel VBA - Passing a variable path with spaces to WinSCP command-line

前端 未结 1 1586
遥遥无期
遥遥无期 2020-12-11 12:36

I have the code at the bottom of this post inside one of my excel books (my first time ever writing vba code). The goal here is to allow users to:

  1. start a vide
相关标签:
1条回答
  • 2020-12-11 13:04

    In WinSCP script, you want:

    put "path with space"
    

    See Command parameters with spaces.


    On WinSCP command line, you have to enclose each command to a double quotes and double all double quotes in the command itself:

    "put ""path with space"""
    

    See WinSCP command-line syntax.


    In VB you need to enclose the string in double quotes and double all double quotes in the string itself:

    """put """"path with space"""""" "
    

    And to replace the path with a variable, substitute the path with space with " & RealFile & ".

    This gives you:

    """put """"" & RealFile & """"""" "
    
    0 讨论(0)
提交回复
热议问题