I thought I might be able to patch this recorded macro, but I simply don't know how.
This is a simple, two-part operation for altering a received Word text document with a styled paragraph indent, so that the indent is removed and a tab is inserted in its place. This is needed prior to pasting the text into ancient mainframe computer documents that require the hard return and subsequent tab to make paragraphs intelligibly separate without an extra line space.
I recorded the macro, which selects everything, changes the first-line indent to 0, replaces every hard return with another followed by a tab, and returns the cursor to the top. I then stripped out all of what appeared to be unnecessary parameters dealing with formatting. The result, however, adds a blank paragraph with a tab at the end of the document, while failing to insert a tab in the first paragraph.
Code:
Sub Macro2()
'
' Macro2 Macro
'
'
Selection.WholeStory
With Selection.ParagraphFormat
.FirstLineIndent = InchesToPoints(0)
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^13"
.Replacement.Text = "^p^t"
.Forward = True
.Wrap = wdFindAsk
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.MoveLeft Unit:=wdCharacter, Count:=1
End Sub
The problem will undoubtedly be obvious to any coder.
Thanks in advance.