0

Preferably I would like to incorporate it into a user form as a command button. The code I've tried so far:

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

Where Updater.mtb is the actual file I would like to execute. This seems to only open Command prompt- which is not what I'm looking for

epietrowicz
  • 334
  • 1
  • 4
  • 16
  • Typically if a Shell argument has spaces you need to enclose it in double-quotes. Try that first. `Call Shell(Environ$("COMSPEC") & " /s """ & mtbPath & "\Updater.mtb""", vbNormalFocus)` – Tim Williams Jul 16 '14 at 16:31
  • I now get a syntax error. – epietrowicz Jul 16 '14 at 18:25
  • Is there a more simple way to go about this? I would just like a button on my user form which runs my executable minitab macro file. – epietrowicz Jul 16 '14 at 18:50

1 Answers1

1

Copy and paste into a VBA Module:

    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
Joe Miller
  • 3,843
  • 1
  • 23
  • 38
Lorne
  • 11
  • 2