Goal: Using VBA in Word, I'd like to be able to type or paste text into a Word document, then make sure each line word wraps at a set amount of characters (typically 50, although this can change). I'd rather not use the ruler at the top of the document to manually adjust, especially when the fonts are not constant-width!
Failed Attempts: I've tried to use the following, resulting in an error "Value out of range":
Public Sub setWordsPerLine()
ActiveDocument.PageSetup.CharsLine = 50
End Sub
I've also tried to insert a return character every 50 characters in a paragraph. However this is leading to a type mismatch error:
For Each pg In ActiveDocument.Paragraphs
b = pg.Range.Characters.Count
c = 50
If b > c Then
For atch = c To pg.Range.Characters.Count Step c
ActiveDocument.Range(pg.Range.Characters(atch)).InsertBefore (Chr(13))
Next
End If
Next
Help Needed:
Is there another method, property, or function that I should be using to do this? Paragraphs.RightIndent = x is based on points, not characters.