Excel VBA: pasar una ruta variable con espacios a la línea de comandos de WinSCP

Tengo el código al final de esta publicación dentro de uno de mis libros de Excel (la primera vez que escribo código vba). El objetivo aquí es permitir a los usuarios:

iniciar una codificación de video usando el software MXLight con un nombre de archivo temporalseleccione una celda con la persona actualmente en videodetenga la codificación de video, cambie el nombre del archivo temporal, muévalo a una carpeta específica, cárguelo a través de FTP a través del software WinSCP, márquelo en verde, mueva una celda hacia abajo.

Entonces, durante el evento, usted:

Presione el botón 1, que es el Sub StartMXLentonces resaltas tu celularPresione el botón 2, que es Sub StopAndProcess

Mis preguntas son las siguientes:

1) En primer lugar, todo el botón (detener y procesar) no funciona porque la función de carga falla, porque no puedo entender cómo hacer que el comando winscp use la variable referenciada ... y no intente literalmente usa esa palabra. Verifique el código debajo de Sub Upload, y aquí está el archivo de registro cuando lo intento:

1 . 2015-11-12 17:53:18.490 Connected
2 . 2015-11-12 17:53:18.490 Using FTP protocol.
3 . 2015-11-12 17:53:18.490 Doing startup conversation with host.
4 > 2015-11-12 17:53:18.491 PWD
5 < 2015-11-12 17:53:18.520 257 "/" is the current directory
6 . 2015-11-12 17:53:18.520 Getting current directory name.
7 . 2015-11-12 17:53:18.520 Startup conversation with host finished.
8 < 2015-11-12 17:53:18.520 Script: Active session: [1] [email protected]
9 > 2015-11-12 17:53:18.520 Script: put RealFile
10. 2015-11-12 17:53:18.520 Copying 1 files/directories to remote directory "/"
11. 2015-11-12 17:53:18.520   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask: 
12. 2015-11-12 17:53:18.520   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: ; ResumeL: 0
13. 2015-11-12 17:53:18.520   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
14* 2015-11-12 17:53:18.520 (EOSError) System Error.  Code: 2.
15* 2015-11-12 17:53:18.520 The system cannot find the file specified

Puede ver en la línea 9 que está tratando de cargar literalmente el archivo llamado "RealFile" en lugar de usar el contenido de la variable con el nombre del archivo y la estructura de la carpeta. Esa variable está funcionando en otras partes del código, como cuando cambio el nombre y la muevo.

¿Alguna idea allí?

Aquí está el código total para todo el asunto:

Public Sub StartMXL()
    Dim MXLapp As String
    MXLapp = "C:\1a7j42w\MXLight-2-4-0\MXLight.exe"
    Shell (MXLapp & " record=on"), vbNormalNoFocus
    AppActivate Application.Caption
End Sub
---
Public Sub StopMXL()
    Dim MXLapp As String
    MXLapp = "C:\1a7j42w\MXLight-2-4-0\MXLight.exe"
    Shell (MXLapp & " record=off"), vbNormalNoFocus
    AppActivate Application.Caption
End Sub
---
Sub ChooseRootDir()
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Please choose a folder"
        .AllowMultiSelect = False
        If .Show = -1 Then Sheets("rawdata").Range("I1").Value = .SelectedItems(1)
    End With
End Sub
---
Public Sub RenameAndMove()
    Dim TempFile As String
    Dim RealFile As String

    If Len(Dir(Sheets("rawdata").Range("I1").Value & "\" & Sheets("rawdata").Range("J1").Value, vbDirectory)) = 0 Then
        MkDir Sheets("rawdata").Range("I1").Value & "\" & Sheets("rawdata").Range("J1").Value
    End If
        If Len(Dir(Sheets("rawdata").Range("I1").Value & "\" & Sheets("rawdata").Range("J1").Value & "\" & Sheets("rawdata").Range("K1").Value, vbDirectory)) = 0 Then
        MkDir Sheets("rawdata").Range("I1").Value & "\" & Sheets("rawdata").Range("J1").Value & "\" & Sheets("rawdata").Range("K1").Value
    End If
        If Len(Dir(Sheets("rawdata").Range("I1").Value & "\" & Sheets("rawdata").Range("J1").Value & "\" & Sheets("rawdata").Range("K1").Value & "\" & Sheets("rawdata").Range("L1").Value, vbDirectory)) = 0 Then
        MkDir Sheets("rawdata").Range("I1").Value & "\" & Sheets("rawdata").Range("J1").Value & "\" & Sheets("rawdata").Range("K1").Value & "\" & Sheets("rawdata").Range("L1").Value
    End If

    TempFile = Sheets("rawdata").Range("I1").Value & "\tempfile\spiderman.TS"
    RealFile = Sheets("rawdata").Range("I1").Value & "\" & Sheets("rawdata").Range("J1").Value & "\" & Sheets("rawdata").Range("K1").Value & "\" & Sheets("rawdata").Range("L1").Value & "\" & ActiveCell.Value & ".TS"

    Name TempFile As RealFile
End Sub
---
Public Sub Upload()
    Dim RealFile As String
    Dim TempFile As String

    RealFile = Sheets("rawdata").Range("I1").Value & "\" & Sheets("rawdata").Range("J1").Value & "\" & Sheets("rawdata").Range("K1").Value & "\" & Sheets("rawdata").Range("L1").Value & "\" & ActiveCell.Value & ".TS"
    TempFile = "C:\1a7j42w\MXLight-2-4-0\recordings\tempfile\spiderman.TS"

    Call Shell( _
    "C:\1a7j42w\WinSCP\WinSCP.com /log=C:\1a7j42w\WinSCP\excel.log /command " & _
    """open ftp://ftp1934501:[email protected]/"" " & _
    """put RealFile"" " & _
    """exit""")
End Sub
---
Sub StopAndProcess()
    Call StopMXL
    Call RenameAndMove
    Call Upload
    Selection.Interior.ColorIndex = 4
    ActiveCell.Offset(1, 0).Select
End Sub

Respuestas a la pregunta(1)

Su respuesta a la pregunta