How to invoke a command programatically from macro or addin?

  • 1
  • Question
  • Updated 6 years ago
  • Answered
I have to start the Word Export addin from code. Is there any solution to achieve this?

1; There is a command with RegisteredName="InteractiveWordExportCommand", but command objects does not have any Execute method. If it's possible executing commands from code, that would be a solution.

2; I've tried directly run
var wordExport = new Mm5WordLib.Mm5WordAddIn();
wordExport.Export(_application.ActiveDocument, "mindjet_export.docx");

but it fails with a System.AccessViolationException on Export:

HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=ExportAddIn
StackTrace:
at Mm5WordLib.IMm5WordAddIn.Export(Document pDocument, String exportFilename)
at ExportAddIn.TopicExportCommand.OnClick() in TopicExportCommand.cs:line 173
InnerException:
Photo of applitecta

applitecta

  • 1 Post
  • 0 Reply Likes

Posted 6 years ago

  • 1
Photo of Nick Duffill

Nick Duffill, Champion

  • 512 Posts
  • 170 Reply Likes
Hello

Unfortunately you cannot use the API to launch built-in MindManager commands or to invoke actions from other add-ins, unless they publish external methods. The Word export is a Mindjet product so I do not have many details, but it almost certainly has a scope that exists during the lifetime of the Mindjet session, rather than just for a document export.

Olympic Ltd has a Word export add-in, and you might be able to persuade them to publish an external method so that export can be invoked by another add-in.

This conversation is no longer open for comments or replies.