Quote:
Originally Posted by Guessed
Converting to text only is akin to throwing the baby out with the bathwater.
|
Agreed, we call it 'nuking' here
Your solutions are much better for one-off situations.
Quote:
Originally Posted by Wordfinder
I didn't get understand what you mean of tag, would you please give more information about how to reserve the source formatting in my doc file after txt step?
|
This is just fyi, as Andrew's solutions above are much better for fixing one or two problems.
I deal with long documents—typically 25-100K words—which may have been thru a lot of different OSs and WP programs. After a frustrating year of trying to track down weird and wonderful problems, I developed a 'nuke and rebuild' process.
Essentially it's a bunch of Global Replace macros before and after the TXT step. So to preserve all italics:
Original doc:
Find all italic text;
Replace each instance with [startItalic]Found Text[EndItalic].
The square brackets' content are the 'tags' I mentioned, they can be anything you like as long as they are unique—ie won't match any legit content.
Code:
Sub IdentifyItalic()
'Surround Italic text with ItalicStart and ItalicEnd to identify it when formatting is stripped.
Selection.Find.ClearFormatting
Selection.Find.Font.Italic = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "ItalicStart^&ItalicEnd"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Post TXT Docx:
Find all the text tagged above, using Wildcards;
Make it Italic;
A later routine deletes all tags and changes direct formatting to styles.
Code:
Sub ItalicRestore()
'Restore Italics [blue for visibility disabled due to problem caused for BaseFix routine]
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Italic = True
' .Color = wdColorBlue
End With
With Selection.Find
.Text = "ItalicStart*ItalicEnd"
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
This approach might be less useful if your original documents are in good shape. It suits me as my input docs can be a mess, so I need to take a hammer and paintbrush to them one way or the other.