1

I am trying to automate minitab with my C# program. I am able to open new minitab window with this code.

    MtbApp = new Mtb.Application();
    MtbProj = MtbApp.ActiveProject;
    MtbUI = MtbApp.UserInterface;
    MtbUI.Visible = true;

This code creates new minitab object and open new minitab window.

Now, my problem is , I dont want to open new minitab window. I want to use the already opened window and execute commands in that. For this I do

MtbApp = Marshal.GetActiveObject("Mtb.Application") as Mtb.Application;

But it always throw exception

Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))

I searched on google for this and i found that mtb should be in Running Object Table. I dont know where ROT is and dont know how to add mtb in ROT.

I also tried by getting opened minitab window handle

    Process[] pr = Process.GetProcessesByName("Mtb");
    Process p = pr[0];
    int hwnd = (int)Process.GetProcessById(pr[0].Id).MainWindowHandle;

but i am not sure how to assign handle to MtbApp object as MtbApp handle is read only property.

Any help will be appreciated.

Thanks

Waqar Ahmed
  • 5,005
  • 2
  • 23
  • 45

0 Answers0