如何使用变量指示目录路径?

问题描述 投票:2回答:1

我必须在VBA中实现某个.exe文件的使用。 .exe将特定类型的文件作为输入,并输出.txt文件。

当我写输入和输出文件的整个目录时,代码起作用。当我分割目录并将零件存储在变量中时,它不是。

我需要分割它,因为我将在不同目录下使用此.exe,以便用户可以选择所需的目录。

Sub convert()

    Dim directory As String
    Dim Filename As String

    directory = "C:\Users\user1\Desktop\reporting\201703161224"
    Filename = "\input.set"

    Shell "cmd /c""C:\Users\user1\Desktop\reporting\appli.exe 
    C:\Users\user1\Desktop\reporting\201703161224\input.set> 
    C:\Users\user1\Desktop\reporting\201703161224\output.txt"
    'this works well

    file = directory & Filename
    Shell "cmd /c""C:\Users\user1\Desktop\reporting\appli.exe file>
    C:\Users\user1\Desktop\reporting\201703161224\output.txt"
    'this doesn't work

End Sub
vba shell path command executable
1个回答
1
投票

Shell = "Hard_Coded_String_1" & file & "Hard_Coded_String_2"

© www.soinside.com 2019 - 2024. All rights reserved.