簡體   English   中英

VBA宏以在Word 2013中的標題編號之前添加空白行

[英]VBA Macro to add a blank line before a header number in Word 2013

經驗豐富的Excel VBA編碼器,Word宏的新手。

我有一個Word 2013文檔輸出,其中包含幾乎300個帶編號的段落,所有段落都以最小的格式一起運行。 段落編號全部從第1列開始,整個文本段落移至5個空格的一個制表符,直到下一個數字返回第1列,依此類推。 直到文檔末尾沒有空白行。

有沒有一種方法可以編寫遍歷整個文檔的宏,並且如果它在第1列中找到一個數字,那么它會在其前面添加一個空行?

非常感謝您的任何幫助。

據我了解,您的文檔如下所示:

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

並且您想要這樣:

. <- 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

在這種情況下,您將不需要宏。 您可以使用Microsoft Word的“ Search and Replace選項以及一些Wildcard

使用搜索替換為Use wildcards激活Use wildcards選項

  • 搜索: [^ 11- ^ 13](<[0-9]>)
  • 替換為: ^ 13 ^ 13 \\ 1

分解:

[^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

有關如何使用此功能的更多信息, 請參見以下頁面: http : //www.gmayor.com/replace_using_wildcards.htm

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM