![]() |
|
#1
|
|||
|
|||
|
Hi all, sorry if my question is off-topic here.
Word used a very bad algorithm to determine where it can break lines (text justification) which has evolved over time, improved considerably, and I know that it is also possible to use the WordPerfect breaking algorithm. My question is. Is it possible to use VBA to modify the justification algorithm/rules used by Word? If not, would it be possible to do that in some other way? I’ve searched a lot but found no results. I suppose that means messing with Word’s justification is not possible. Nevertheless, I wanted to check here. |
|
#2
|
||||
|
||||
|
You can only choose one of the line-wrap algorithms built into the program itself (e.g. WordPerfect, as you noted).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Are there more?
Excluding Word native. |
|
#4
|
||||
|
||||
|
Word changed the justification algorithm with the introduction of Word 2013. Presumably, saving it with compatibility for Word 2010 or earlier will default to the older algorithm.
See: Document.SaveAs2 method (Word) | Microsoft Learn and WdCompatibilityMode enumeration (Word) | Microsoft Learn As for other justification options, see: WdParagraphAlignment enumeration (Word) | Microsoft Learn. I haven't tried the JustifyHi/Low/Med options, so I can't tell you what they do.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
This is really new to me. Thank you!
Is there a way to choose between different settings, e.g. to specifically choose wdAlignParagraphJustifyHi? |
|
#6
|
||||
|
||||
|
The WdParagraphAlignment constants apply to the .ParagraphFormat.Alignment property.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#7
|
|||
|
|||
|
Sorry, I am a complete beginner with VBA so I must ask like this. In the specifications you sent me, there were the following:
wdAlignParagraphJustifyLow-Justified with a low character compression ratio. wdAlignParagraphJustifyHi-Justified with a high character compression ratio. Is it possible to choose one enumeration and apply it to the whole document/or selected part, or is that something that is not possible to apply? |
|
#8
|
||||
|
||||
|
Well, yes, you could do that quite simply with a macro like:
Code:
Sub Demo() ActiveDocument.Range.ParagraphFormat.Alignment = wdAlignParagraphJustifyLow End Sub Code:
Sub Demo() Selection.Range.ParagraphFormat.Alignment = wdAlignParagraphJustifyHi End Sub For PC macro installation & usage instructions, see: Installing Macros For Mac macro installation & usage instructions, see: https://wordmvp.com/Mac/InstallMacro.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#9
|
|||
|
|||
|
Thanks for the answer and code.
I will try macros and report back if there is any visible change in the text appearance.
|
|
#10
|
|||
|
|||
|
Here is what these options do. They are not substitutes for WordPerfect justification.
Text justified with Code:
wdAlignParagraphJustifyHi Code:
wdAlignParagraphJustifyLow |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Word 2016: Stop merged cells from breaking across pages
|
FiveFingers | Word Tables | 3 | 06-26-2024 08:20 PM |
word erases line bottom in tight line spacing when new line is added
|
ozzzy | Word | 2 | 01-21-2021 06:41 AM |
| Controlling line breaking when using Shrink Text on Overflow | catflap | Publisher | 0 | 03-08-2018 02:08 AM |
Sorting algorithm for two dimensional array
|
NobodysPerfect | Word VBA | 1 | 04-07-2014 03:58 PM |
| Formula for algorithm | santiago_dl | Excel | 0 | 01-11-2012 11:09 AM |