[英]Executable not running correctly after being called from a VBA Excel Macro
我有一个可执行文件“ Operate.exe”,该文件从文本文件“ Weightings.txt”中读取数据并对其执行一些操作。 单独执行时,运行良好。
我正在尝试使用VBA从excel中的按钮执行此操作。 该程序运行,但未打开/找到“ weightings.txt”。
这是我在VBA中使用的代码:
Sub TextBox1_Click()
Shell ThisWorkbook.Path & "\Operate.exe", vbNormalFocus
End Sub
该文件夹包含Operate.exe,Operate.pdb,Game.xlsm和Weightings.txt。
是否由于从VBA运行exe程序而找不到Weightings.txt?
将当前的默认工作目录更改为ThisWorkbook.Path。
Sub TextBox1_Click()
Debug.Print CurDir
ChDir ThisWorkbook.Path
Debug.Print CurDir
Shell ThisWorkbook.Path & "\Operate.exe", vbNormalFocus
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.