#1
|
|||
|
|||
Macro for paragraphs with numbering and hanging
Hello everyone. Hope you can help me with this macro as my VBA knowledge is not good enough yet.
This is the macro that I need: For all paragraphs defined with numbering, I need to ensure that hanging is set to "1 cm". When I review my document and find an instance where the hanging is not 1 cm, I need to correct this is by opening the Paragraph menu, then "Indents and Spacing" and change the settings here: Special: Hanging Defined: 1,08 cm >>> 1 cm This is very time consuming so I hope anyone help me with that. In addition, if the macro can also report the instances which were fixed in some way or at least reporting that all hangings are set correctly to 1 cm, it would be fantastic. Anyway, I don´t mind if this is not possible. I have enough if the macro can simply check and change all paragraphs with numbering to "1 cm". Thank you! |
#2
|
||||
|
||||
Your numbered paragraphs ought to be using one or more suitably-defined Styles, in which case you could get the required format just by setting the Style definition(s) appropriately.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
The document does not have any styles applied in 200 pages, so better using a macro for that.
|
#4
|
||||
|
||||
Not so - simply use Find/Replace to apply the relevant Style
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
The document MUST NOT HAVE any style. Sorry for not mentioned this limitation in my previous response.
So, there is no way to use a Macro in order to set the hanging to 1cm to all paragraphs with numbering in a document? |
#6
|
||||
|
||||
ALL Word documents have styles. Word is a style based format. You cannot avoid using them so why try and work around them? It makes no sense and leads to the sort of dilemma you are now facing.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#7
|
|||
|
|||
I´m following up the post above.
@Thanks gmayor for your response and for "enlightening" me on this matter. I have now realized the following: - The hanging is applied in my document to different Styles: numberings, titles, subtitles, bulleted list etc... - I have also noted that there are million of Styles in my document, so it takes too many time to identify the Style in the list menu and then checking if the hanging is correctly set to "1 cm". I´m wondering if there is any way to skip the Styles to ensure that hanging is set to "1 cm". For example, searching for any instance of hanging lower or higher than "1 cm" throughout the document. Would that be possible? Many thanks in advance! When I review my document and find an instance where the hanging is not 1 cm, I need to correct this is by opening the Paragraph menu, then "Indents and Spacing" and change the settings here: ALL Word documents have styles. Word is a style based format. You cannot avoid using them so why try and work around them? It makes no sense and leads to the sort of dilemma you are now facing. |
#8
|
||||
|
||||
This macro will help you standardise your document's hanging indents AND makes use of styles. It will greatly reduce inconsistency in your styling of the document because it is resetting the paragraph formats and removes local paragraph overrides.
Code:
Sub AllStylesSetHanging() Dim aStyle As Style For Each aStyle In ActiveDocument.Styles If aStyle.Type = wdStyleTypeParagraph Then If aStyle.ParagraphFormat.FirstLineIndent < 0 Then aStyle.ParagraphFormat.FirstLineIndent = -CentimetersToPoints(1) If aStyle.ParagraphFormat.LeftIndent < CentimetersToPoints(1) Then aStyle.ParagraphFormat.LeftIndent = CentimetersToPoints(1) End If End If End If Next aStyle ActiveDocument.Range.ParagraphFormat.Reset End Sub If you see other non-hanging paragraphs change as a result of this macro, you should apply the right styles to those paragraphs.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#9
|
|||
|
|||
I have tested the Macro but, as you said, it is resets all paragraph formats, even the ones that I want to keep as they are.
Rather than reapplying the right styles where needed after running the macro, would it be possible to tweak the code so that the hanging (1 cm) is applied to 2 styles only? For example, "Title1" and "Heading 1" Many thanks! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Updating hyperlinks in a document where clauses are deleted and auto numbering of paragraphs change | Angela Jackson | Word | 2 | 03-21-2018 02:42 AM |
Macro to hide all paragraphs that do not have the found result | jplat | Word VBA | 1 | 09-10-2017 09:13 PM |
Continue Numbering Paragraphs | PJinNH | Word | 5 | 03-15-2017 04:10 PM |
Macro for hanging indent and single space | pbishop | Word | 2 | 09-11-2016 06:49 PM |
Macro that changes color of all indented paragraphs | muiy | Word | 4 | 08-01-2016 08:18 PM |