0

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

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 是我想要执行的实际文件。这似乎只打开命令提示符 - 这不是我要找的

4

1 回答 1

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
于 2015-03-10T15:17:50.383 回答