【发布时间】:2020-06-12 18:19:29
【问题描述】:
我必须在 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