Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-04-2018, 01:56 AM
Pintus Pintus is offline Macro for paragraphs with numbering and hanging Windows XP Macro for paragraphs with numbering and hanging Office 2010 64bit
Novice
Macro for paragraphs with numbering and hanging
 
Join Date: May 2018
Posts: 7
Pintus is on a distinguished road
Default 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!
Reply With Quote
  #2  
Old 05-05-2018, 03:59 AM
macropod's Avatar
macropod macropod is offline Macro for paragraphs with numbering and hanging Windows 7 64bit Macro for paragraphs with numbering and hanging Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 05-05-2018, 08:26 AM
Pintus Pintus is offline Macro for paragraphs with numbering and hanging Windows XP Macro for paragraphs with numbering and hanging Office 2010 64bit
Novice
Macro for paragraphs with numbering and hanging
 
Join Date: May 2018
Posts: 7
Pintus is on a distinguished road
Default

The document does not have any styles applied in 200 pages, so better using a macro for that.
Reply With Quote
  #4  
Old 05-05-2018, 11:37 PM
macropod's Avatar
macropod macropod is offline Macro for paragraphs with numbering and hanging Windows 7 64bit Macro for paragraphs with numbering and hanging Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Not so - simply use Find/Replace to apply the relevant Style
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-06-2018, 11:56 PM
Pintus Pintus is offline Macro for paragraphs with numbering and hanging Windows XP Macro for paragraphs with numbering and hanging Office 2010 64bit
Novice
Macro for paragraphs with numbering and hanging
 
Join Date: May 2018
Posts: 7
Pintus is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Not so - simply use Find/Replace to apply the relevant Style
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?
Reply With Quote
  #6  
Old 05-07-2018, 12:27 AM
gmayor's Avatar
gmayor gmayor is offline Macro for paragraphs with numbering and hanging Windows 10 Macro for paragraphs with numbering and hanging Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #7  
Old 05-17-2018, 08:31 AM
Pintus Pintus is offline Macro for paragraphs with numbering and hanging Windows XP Macro for paragraphs with numbering and hanging Office 2010 64bit
Novice
Macro for paragraphs with numbering and hanging
 
Join Date: May 2018
Posts: 7
Pintus is on a distinguished road
Default

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.
Reply With Quote
  #8  
Old 05-17-2018, 02:00 PM
Guessed's Avatar
Guessed Guessed is offline Macro for paragraphs with numbering and hanging Windows 10 Macro for paragraphs with numbering and hanging Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,994
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Whilst we could choose to write the macro differently to deal with local settings on every paragraph, that macro would run very slowly and result in a poorly formatted file which is why you have had pushback on your asked-for approach.
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
Reply With Quote
  #9  
Old 05-18-2018, 06:09 AM
Pintus Pintus is offline Macro for paragraphs with numbering and hanging Windows XP Macro for paragraphs with numbering and hanging Office 2010 64bit
Novice
Macro for paragraphs with numbering and hanging
 
Join Date: May 2018
Posts: 7
Pintus is on a distinguished road
Default

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!
Reply With Quote
Reply



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 for paragraphs with numbering and hanging 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 for paragraphs with numbering and hanging Macro that changes color of all indented paragraphs muiy Word 4 08-01-2016 08:18 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:34 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