D
David Turner
I still get quite a lot of documents formatted typewriter style with the
space bar and tabs being used to left indent text.
I know leading spaces and tabs can be stripped by selecting the text, center
justifying the selection and then left justifying the selection, but this
also removes the indent.
I'd thus like to be able to remove a space or tab and adjust the left indent
accordingly so the document "looks" the same.
This macro seems to go half way there but I can seem to find a way to move
the indent left by a single space. ParagraphFormat.IndentCharWidth 1 seems to
left indent to the next tab stop rather than just by one character width.
Sub StripTabsAndSpaces()
Dim oPRg As Paragraph
Dim DoTab As Long
Dim i As Long
i = 0
For Each oPRg In ActiveDocument.Paragraphs
While oPRg.Range.Characters.First = vbTab
oPRg.Range.Characters.First = ""
DoTab = (i + 1)
oPRg.Range.ParagraphFormat.TabIndent (DoTab)
Wend
While oPRg.Range.Characters.First = " "
oPRg.Range.Characters.First = ""
oPRg.Range.ParagraphFormat.IndentCharWidth 1
Wend
Next
End Sub
Any help would be greatly appreciated.
Regards,
David Turner
space bar and tabs being used to left indent text.
I know leading spaces and tabs can be stripped by selecting the text, center
justifying the selection and then left justifying the selection, but this
also removes the indent.
I'd thus like to be able to remove a space or tab and adjust the left indent
accordingly so the document "looks" the same.
This macro seems to go half way there but I can seem to find a way to move
the indent left by a single space. ParagraphFormat.IndentCharWidth 1 seems to
left indent to the next tab stop rather than just by one character width.
Sub StripTabsAndSpaces()
Dim oPRg As Paragraph
Dim DoTab As Long
Dim i As Long
i = 0
For Each oPRg In ActiveDocument.Paragraphs
While oPRg.Range.Characters.First = vbTab
oPRg.Range.Characters.First = ""
DoTab = (i + 1)
oPRg.Range.ParagraphFormat.TabIndent (DoTab)
Wend
While oPRg.Range.Characters.First = " "
oPRg.Range.Characters.First = ""
oPRg.Range.ParagraphFormat.IndentCharWidth 1
Wend
Next
End Sub
Any help would be greatly appreciated.
Regards,
David Turner