1
votes

Fairly experienced Excel VBA coder, newbie for Word macros.

I have a Word 2013 document output with almost 300 numbered paragraphs that all run together with minimal formatting. The paragraph numbers all start in column 1, with the whole text paragraph shifted over one tab of 5 spaces, until the next number which is back in column 1 and so on. No blank lines until the end of the document.

Is there a way to write a macro that cycles through the entire document, and if it finds a number in column 1, that it then adds a blank line before it?

Many thanks in advance for any help.

1
Are the numbers actual bullets?Tim Williams
No bullets, just numbering starting with 1. and a heading, then the text as an indented paragraph, followed by 2. and a heading, and so on.parodytx

1 Answers

0
votes

To what I understand your document looks like this:

1     Heading
test test test
2     Other heading
test test test
test 33test test
test test test2
test test test
test 44 test test
test test test
3     Other heading

And you would like to have it like this:

. <- would represent a empty line 
1     Heading
test test test

2     Other heading
test test test
test 33test test
test test test2
test test test
test 44test test
test test test

3     Other heading

In such a case you won't need a macro. You could use the Search and Replace option of Microsoft Word and some Wildcard magic.

Use Search Replace with the option Use wildcards activated

  • Search for: [^11-^13](<[0-9]>)
  • Replace with: ^13^13\1

Breakdown:

[^11-^13](<[0-9]>)

^11       = Shift-Enter (New line)
^13       = Enter (Paragrah)
[]        = Marks the range of the two characters
[^11-^13] = Will find any Shift-Enter or Enter character
()        = Marks a group
<>        = Marks the start and end of a word
[0-9]     = Will find a single character 0-9

^13^13\1

^13 = inserts a paragraph
\1  = inserts the group marked in the search string

For more information on how to use this feature look at this page: http://www.gmayor.com/replace_using_wildcards.htm