对,情况优先:
我希望能够发出一些命令,只需点击一下按钮即可执行所有这些操作。到目前为止,我有这个:
Public Sub Execute_Mathcad()
Dim x As Variant
Dim Path As String
Dim File As String
'save application in current form (should be up to date)
ThisWorkbook.Save
'pause vb script so mathcad can run normally
Application.Wait (Now + TimeValue("0:00:20"))
'open the external program
Path = "C:\Program Files (x86)\Mathcad\Mathcad 15\mathcad.exe"
File = "C:\Users\blah\blah.xmcd"
x = Shell(Path + " " + File, vbNormalFocus)
'issue CTRL+F9 in active program - can the keystroke be issued through windows directly (this solves and saves the MathCad program)
SendKeys ("^{F9}")
'exit mathcad using VBA command
'import results (I have code for this)
End Sub
我的主要问题似乎是如何暂停excel并允许外部程序运行。它在excel打开时无法运行,因为它必须出于某种原因从工作簿中提取数据?
其次,如何在外部程序中发出键盘快捷键(例如CTRL + F9)
谢谢!
答案 0 :(得分:0)
编写将启动MathCad,关闭Excel,然后重新启动Excel并执行结果导入的bat或vbs文件。从shell命令调用该文件,就像您当前打开MathLab一样。