S
Sammy
Hi,
I have created a macro that will extract the text out of a corrupted or
messed up Word document and paste special unformatted into a new document
container (selecting everything except the last paragraph mark attached to
text). Of course the user has to reformat the new document. This is also
used for converting WordPerfect documents. I would like to be able to add
any existing Bold, Italic and Underline font formatting back into the new
document, as it was in the original document. I've tried a few things but no
success yet, for example entering "zzb" "zzi" and "zzu" before and after
formatted text in the original document but I'm really stuck on how this can
be done. Any ideas would be appreciated. Here's my cleanup macro (yes, all
my macros are really basic but I'm having fun learning VBA):
Sub CleanUp()
If Documents.Count = 0 Then Exit Sub
Selection.EndKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindAsk
.Format = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.Cut
ActiveWindow.Close wdDoNotSaveChanges
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
Selection.HomeKey Unit:=wdStory
End Sub
Thank you
I have created a macro that will extract the text out of a corrupted or
messed up Word document and paste special unformatted into a new document
container (selecting everything except the last paragraph mark attached to
text). Of course the user has to reformat the new document. This is also
used for converting WordPerfect documents. I would like to be able to add
any existing Bold, Italic and Underline font formatting back into the new
document, as it was in the original document. I've tried a few things but no
success yet, for example entering "zzb" "zzi" and "zzu" before and after
formatted text in the original document but I'm really stuck on how this can
be done. Any ideas would be appreciated. Here's my cleanup macro (yes, all
my macros are really basic but I'm having fun learning VBA):
Sub CleanUp()
If Documents.Count = 0 Then Exit Sub
Selection.EndKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindAsk
.Format = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.Cut
ActiveWindow.Close wdDoNotSaveChanges
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
Selection.HomeKey Unit:=wdStory
End Sub
Thank you