Drafts action to copy text into Microsoft word document

Hi,

I’m trying to create a Drafts action that will take markdown, convert it to rich text and then copy to Microsoft Word. I’m using an action I found on the action directory…

// Process Markdown to HTML

var mmd = MultiMarkdown.create();

var html = mmd.render(draft.content);

// Wrap raw MMD output with HTML template with styles to set base fonts.

var template = `<html>

<body style=“font-family:Verdana;”>

[[content]]

</body>

</html>

`;

var html = template.replace("[[content]]", html);

// Place in clipboard as rich-text

if (!app.htmlToClipboard(html)) {

context.fail(“Error rendering rich text from HTML.”);

}

And then using a Siri Shortcut to convert HTML to rich text and open application. Issue is that whenI do this, I don’t see Microsoft word as one of the applications I can open.

So far, the only way I can find to do this is to run the Drafts action above manually open Word, and manually paste text. It works but its clumsy and I’d like to save a few steps.

Any thoughts?

Not sure how the Shortcuts “Open App” step gets it list of apps, but I have Word installed and am able to select it as an option. ¯_(ツ)_/¯

Alternatively you can call Word with an Open URL action (but you can’t get it to add the content automatically):

https://docs.microsoft.com/en-us/office/client-developer/office-uri-schemes

It’s all under-documented and you’ll need to use ms-word:// in the url not just ms-word: as shown there.

Thanks for the replies. I was able to get word to show up in the Shortcuts application. Now I’m seeing this error message.

I get this message whether I’m trying to pass markdown to Shortuts or html. Has anyone tried to getting an action / shortcut like this to work? My company using Word quite a bit so this would be very helpful to me.

Thank you in advance.

Well I tried a bit and by adding a file name ending in docx and saving it before the Open In… action, I got Word to try to open it, but it failed.

See https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_imobile-mso_365hp/no-rtf-support-in-word-on-ipad/7a1b946c-2225-4a7f-bab9-a8c0fd3d155e

If you have it, your best bet is probably to put your Markdown in Ulysses which natively can export to docx files which open right up in Word for iPad,

Any actions for this?