Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2020, 07:41 AM
MrBill51 MrBill51 is offline Unindent Initial Chapter and Section Paragraphs in Novel Windows 10 Unindent Initial Chapter and Section Paragraphs in Novel Office 2010
Novice
Unindent Initial Chapter and Section Paragraphs in Novel
 
Join Date: May 2020
Posts: 2
MrBill51 is on a distinguished road
Default 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
Until eight thirty, when her unexpected visitor appeared...




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:


#
"I was framed," thundered the leading Democratic contender for the presidency.




Thanks very much for your help.
Reply With Quote
  #2  
Old 05-19-2020, 09:02 AM
gmaxey gmaxey is offline Unindent Initial Chapter and Section Paragraphs in Novel Windows 10 Unindent Initial Chapter and Section Paragraphs in Novel Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 05-20-2020, 06:16 AM
MrBill51 MrBill51 is offline Unindent Initial Chapter and Section Paragraphs in Novel Windows 10 Unindent Initial Chapter and Section Paragraphs in Novel Office 2010
Novice
Unindent Initial Chapter and Section Paragraphs in Novel
 
Join Date: May 2020
Posts: 2
MrBill51 is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 05-20-2020, 07:03 AM
gmaxey gmaxey is offline Unindent Initial Chapter and Section Paragraphs in Novel Windows 10 Unindent Initial Chapter and Section Paragraphs in Novel Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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).
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Thread Tools
Display Modes


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
Unindent Initial Chapter and Section Paragraphs in Novel 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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft