#1
|
|||
|
|||
Unindent Initial Chapter and Section Paragraphs in Novel
I am formatting a novel for publication. The standard format for a novel is for the first paragraph of each chapter and section to be unindented. All other paragraphs are indented. My novel-writing software can't distinguish a first paragraph from any other, so all my paragraphs are indented.
For the chapter breaks, I need a Word VBA macro that will find the word "CHAPTER" followed by a number, skip over the title below it ("Clement's Lament"), and unindent the first paragraph ("Until eight thirty..."), and then move to the next instance of "CHAPTER" followed by a number and do the same thing throughout the document. Example: CHAPTER 1 Clement's Lament Section breaks are designated by a pound sign. For the section breaks, the macro needs to find each instance where the symbol "#" is on its own line and unindent only the first paragraph below it and then do the same for each "#" throughout the document. Example: # Thanks very much for your help. |
#2
|
|||
|
|||
Mr Bill,
This is a freebie, but this also isn't a code writing service and you should make some attempt before asking for the solution on a platter. Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find .Text = "Chapter [0-9]@" .MatchWildcards = True While .Execute oRng.Move wdParagraph, 2 oRng.Paragraphs(1).Style = "Normal" 'You should create some named style for your first paragraphs and replace "Normal" with it. oRng.Collapse wdCollapseEnd Wend End With lbl_Exit: Exit Sub End Sub |
#3
|
|||
|
|||
Thanks for your suggestion. It didn't work, but I managed to tweak it and now it works great, without the need to create any styles. Here's the code:
Sub FixNovelFormat() 'Fix the first-line indentation of Scrivener Word output file Set myRange = ActiveDocument.Content 'Remove indentation from third paragraph below the word "CHAPTER" With myRange.Find .Text = "CHAPTER" While .Execute myRange.Collapse Direction:=wdCollapseStart myRange.Move Unit:=wdParagraph, Count:=3 myRange.ParagraphFormat.FirstLineIndent = InchesToPoints(0) myRange.Collapse wdCollapseEnd Wend End With 'Remove indentation from the paragraph below the hashtag Set myRange = ActiveDocument.Content With myRange.Find .Text = "#" While .Execute myRange.Collapse Direction:=wdCollapseStart myRange.Move Unit:=wdParagraph, Count:=1 myRange.ParagraphFormat.FirstLineIndent = InchesToPoints(0) myRange.Collapse wdCollapseEnd Wend End With End Sub |
#4
|
|||
|
|||
Bill,
The first didn't work because I used "Chapter" instead of "CHAPTER" the second didn't work because I didn't see it. Sorry. What you have done now is create a document full of "direct formatted" paragraphs (one for each chapter and one for each section). Much of the power within Word is within Word styles. For example, you could have a title "CHAPTER" followed by as style "Title" followed by a style "Body Text" (that has no first line indent) followed by a style Body Text First Line Indent (that does). |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Chapter page references in paragraphs | kenking | Word | 12 | 02-07-2020 03:33 PM |
Adding chapter or section numbers to 'Page Number' | JStephens3 | Word | 2 | 07-02-2019 01:45 PM |
Footer: chapter and section names | tropaj | Word | 7 | 05-22-2019 03:56 PM |
Need "Section 1" numbering which is followed by 1.1 Chapter titles and 1.2.3 subs | xmlgirl | Word | 1 | 02-26-2014 12:31 AM |
using odd-Even chapter footers with page number and chapter titles | Fossils13 | Word | 0 | 07-17-2010 06:49 AM |