Lightweight VBA solution to paste Markdown into Microsoft Word or Outlook and avoid manual formatting.
PasteMarkdown is a VBA macro for Microsoft Word and Outlook that converts clipboard Markdown into formatted Office content, including headings, lists, tables, bold and italic text, code blocks, links, task lists, and more.
It is useful for inserting Markdown, including AI-generated text, into Word documents or Outlook emails without manually reformatting the content.
- Headings:
#to######converted to Word Heading 1 to Heading 6 styles - Unordered lists:
-,*, and+converted to bullet lists - Ordered lists:
1.,2.,3.converted to numbered lists - Nested lists: Basic nesting support based on leading spaces
- Task lists:
- [ ]and- [x]converted to checkbox-style task items - Bold and italic:
**bold**__bold__*italic*_italic_***bold italic***___bold italic___
- Blockquotes:
> quoted textconverted to Word Quote style - Fenced code blocks: Triple backtick code blocks converted to a monospaced, shaded Code style
- Inline code:
`code`converted to Consolas with shading - Strikethrough:
~~strike~~converted to strikethrough formatting - Links:
https://example.comconverted to live hyperlinks - Markdown tables: Standard pipe tables converted to native Word or Outlook tables
- Table alignment:
:---for left alignment:---:for center alignment---:for right alignment
- Escaped pipes in tables:
\|supported inside table cells - Line breaks inside table cells:
<br>,<br/>, and<br />converted to line breaks inside the cell
-
Word version
- Macro name:
PasteMarkdownToWord - Designed to paste Markdown directly into Microsoft Word documents.
- Macro name:
-
Outlook version
- Macro name:
PasteMarkdownToEmail - Designed to paste Markdown directly into the Outlook email editor.
- Uses Outlook's Word-based email editor.
- Macro name:
- Open Microsoft Word.
- Press
Alt + F11to open the VBA editor. - Insert a new module.
- Paste the Word version of the code into the module.
- Place your cursor where you want to insert the formatted content.
- Copy Markdown content to the clipboard.
- Run the
PasteMarkdownToWordmacro.
- Open Microsoft Outlook.
- Press
Alt + F11to open the VBA editor. - Insert a new module.
- Paste the Outlook version of the code into the module.
- Enable the required Word reference as described in the Dependencies section.
- Open a new email, reply, or forward.
- Place your cursor where you want to insert the formatted content.
- Copy Markdown content to the clipboard.
- Run the
PasteMarkdownToEmailmacro.
For faster access, add the macro to the Ribbon or Quick Access Toolbar, or assign a keyboard shortcut where supported.
No additional references are required when running the Word version inside Microsoft Word.
The Word object model is already available in Word VBA.
The Outlook version uses Outlook's built-in Word email editor and early-bound Word objects such as:
Word.Document
Word.Selection
Word.Range
Word.TableTherefore, in the Outlook VBA editor, enable:
Microsoft Word 16.0 Object Library
Depending on your Office version, the number may differ, for example:
Microsoft Word 15.0 Object Library
Microsoft Word 16.0 Object Library
The Outlook object model is already available when running the code inside Outlook VBA.
No explicit reference to Microsoft VBScript Regular Expressions 5.5 is required.
The modules use late binding:
CreateObject("VBScript.RegExp")Because of this, the regex library does not need to be manually enabled under Tools > References.
PasteMarkdown supports standard Markdown pipe tables. This is converted into a native Word or Outlook table with:
- Header row formatting
- Borders
- Basic cell padding
- Column alignment based on the separator row
Both modules include this setting near the top:
Private Const REMOVE_EMPTY_PARAGRAPHS_AFTER_PASTE As Boolean = FalseDefault:
FalseThis preserves paragraph spacing, which is usually better for business documents and emails. I found that in Word it is better to set it to True.
The macro follows this sequence:
- Paste clipboard content as plain text.
- Process only the newly pasted content.
- Normalize manual line breaks.
- Convert fenced code blocks.
- Convert Markdown tables.
- Apply headings, quotes, lists, task lists, inline code, bold, italic, links, and strikethrough.
- Optionally remove empty paragraphs.
This order is intentional. Code blocks are protected before inline formatting, and tables are converted before the remaining paragraph-level formatting is applied.
PasteMarkdown covers common Markdown used in business documents, emails, meeting notes, summaries, and AI-generated responses.
It does not currently support:
- Images:
url - Footnotes and references:
[^1],url - Nested blockquotes deeper than one level
- Definition lists
- Math formulas
- Raw HTML blocks
- Merged table cells
- Multiline Markdown tables beyond simple
<br>line breaks inside cells - Complex nested Markdown inside table cells
- Links with complex URLs containing unmatched closing parentheses
This project is released under the MIT License. See LICENSE for details.