Skip to content

Instantly share code, notes, and snippets.

@sandraros
sandraros / vba_word_tabs_to_spaces_or_markdown
Last active January 19, 2019 19:51
VBA macro to paste into MS Word, which converts text lines with tab characters representing tables into tables without tab, but instead with values right-padded with spaces (markdown version too) so that to fit perfectly for usage of HTML <pre>...</pre>
Rem 1) select the text lines representing a table whose columns are separated by the tab character
Rem 2) run this macro
Rem 3) result: the tab characters are replaced by two or more space characters such a way each column
Rem has the same number of characters
Rem 4) you may then copy/paste those text lines inside HTML <pre>...</pre> it will look like a table
Sub tabs_to_spaces()
Dim par As Paragraph
Dim pars() As Paragraph
Dim arr(50) As Integer ' 50 tabs maximum per line