709-218-7927

The Landfall Garden House

60 Canon Bayley Road

Bonavista, Newfoundland

CANADA A0C 1B0

CPRGreaves@gmail.com

Home

Christopher Greaves

Rebuild your Active Document

Wednesday, August 31, 2011

Your document is corrupt, or it is so heavily edited that it is behaving badly.

Use the little macro "RebuildActiveDocument" to grab all your text, unformatted, and rebuild the document.

CAUTION: make a copy of your document using Windows Explorer before running this macro.

Sub RebuildActiveDocument()

' Get the name of the source ActiveDocumentument

Dim strFilename As String

strFilename = ActiveDocument.FullName

' Get the stoty-content of the ActiveDocumentument

Dim strStoryContent As String

Dim lng As Long

For lng = 1 To ActiveDocument.StoryRanges.Count

strStoryContent = strStoryContent & ActiveDocument.StoryRanges(lng).Text

Next lng

' Close the ActiveDocumentument WITHOUT saving changes

ActiveDocument.Close (wdDoNotSaveChanges)

' Create a new ActiveDocumentument

Documents.Add

' Insert the text file

Selection.TypeText (strStoryContent)

' Save the ActiveDocumentument with the original name

ActiveDocument.SaveAs (strFilename)

End Sub

709-218-7927 CPRGreaves@gmail.com

Bonavista, Sunday, December 08, 2024 9:32 AM

Copyright © 1990-2024 Chris Greaves. All Rights Reserved.