【问题标题】:How can I run a MiniTab Executable file (.mtb) in vba如何在 vba 中运行 MiniTab 可执行文件 (.mtb)
【发布时间】:2014-07-16 16:29:06
【问题描述】:

最好我想将它作为命令按钮合并到用户表单中。 到目前为止我尝试过的代码:

Private Sub graphButton_Click()

    Dim mtbPath As String: mtbPath = "S:\MetLab (Protected)\MetLab Operations\Lab 
    Reports\Forgings"

    Call Shell(Environ$("COMSPEC") & " /s " & mtbPath & "\Updater.mtb", vbNormalFocus)

End Sub

Updater.mtb 是我想要执行的实际文件。这似乎只打开命令提示符 - 这不是我要找的

【问题讨论】:

  • 通常,如果 Shell 参数有空格,则需要将其括在双引号中。先试试那个。 Call Shell(Environ$("COMSPEC") & " /s """ & mtbPath & "\Updater.mtb""", vbNormalFocus)
  • 我现在遇到语法错误。
  • 有没有更简单的方法来解决这个问题?我只想在我的用户表单上有一个按钮来运行我的可执行 minitab 宏文件。

标签: vba excel userform commandbutton minitab


【解决方案1】:

复制并粘贴到 VBA 模块中:

    Sub Run_Minitab_Macro()

    Set MtbApp = CreateObject("Mtb.Application")

    With MtbApp.ActiveProject
    'This lets you open an excel file from your desktop:
    .ExecuteCommand "WOpen 'C:\Users\you\Desktop\TEMP1.xlsx'; FType; Excel." 
    'Save the minitab project to my documents:
    .ExecuteCommand "Save  'C:\Users\you\My Documents\Test.MPJ'; Project; Replace."
    'On Error Resume Next
    .ExecuteCommand "%MacroFile" 'This is a .MAC macro file stored in the my 
                                 'documents folder saved to here, 
                                 'any command-line command can go here though
    'On Error GoTo 0
    .ExecuteCommand "Save."
    End With

    End Sub

【讨论】:

    猜你喜欢
    • 2022-01-05
    • 2014-09-16
    • 1970-01-01
    • 1970-01-01
    • 2013-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多