How to open documents by using the Open and Repair feature in Word 2002 and Word 2003 (893672)



The information in this article applies to:

  • Microsoft Office Word 2003
  • Microsoft Word 2002

INTRODUCTION

This article describes how to open documents by using the Open and Repair feature in Microsoft Word 2002 and Microsoft Office Word 2003.

MORE INFORMATION

Microsoft Word automatically uses the Open and Repair feature if Word detects a problem with a document when you open it. However, you can force Word to use the Open and Repair feature when you open any document. This may be especially useful when you intend to save the document in a different file format. If you save a damaged document in a different file format, you may not be able to open the saved document. For more information about how to troubleshoot damaged Word documents, click the following article number to view the article in the Microsoft Knowledge Base:

826864 How to troubleshoot damaged Word documents

To open a document by using the Open and Repair feature in Word, use one of the following methods.

Method 1: To open a specific document

To open a specific document by using the Open and Repair feature in Word, follow these steps:
  1. Start Word.
  2. On the File menu, click Open.
  3. In the Open dialog box, click to select the file that you want to open.
  4. Click the down arrow on the Open button, and then click Open and Repair.

Method 2: To open all documents

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To open all documents by using the Open and Repair feature in Word, replace the built-in FileOpen macro in Word with a Microsoft Visual Basic for Applications (VBA) macro. To do this, follow these steps:
  1. Start Word, and then open a new blank document.
  2. On the Tools menu, point to Macro, and then click Macros.
  3. Click the down arrow in the Macros in box, and then click Word commands.
  4. In the Macro name list, click FileOpen.
  5. Click the down arrow in the Macros in box, and then click Normal.dot (global template).
  6. Click Create.
  7. The built-in FileOpen macro appears as in the following example:
    Sub FileOpen()
    '
    ' FileOpen Macro
    ' Opens an existing document or template
    '
        Dialogs(wdDialogFileOpen).Show
    
    End Sub
    
  8. Replace the built-in FileOpen macro with the following macro example:
    Option Explicit
    
    ' WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS EXAMPLE IS
    ' AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of
    ' any kind, either expressed or implied, including but not limited to the implied 
    ' warranties of merchantability and/or fitness for a particular purpose.
    
    Sub FileOpen()
    '
    ' FileOpen Macro
    ' Opens an existing document or template
    '
    Dim sFileName As String
    
    ' Display the File Open dialog and capture the filename selected and pass it to a
    ' variable
    With Application.Dialogs(wdDialogFileOpen)
        .Display
        sFileName = .Name
    End With
    
    ' Test to verify the filename has a value
    ' If no file is chosen or if the Open dialog is dismissed, 
    ' the following code is skipped
    If sFileName <> "" Then
        ' Use the filename as a variable to be opened using Open and Repair feature
        Documents.Open FileName:=sFileName, OpenAndRepair:=True
    End If
    
    End Sub
    
  9. On the File menu, click Close and Return to Microsoft Word.
  10. On the File menu, press SHIFT, and then click Save All.
Notes
  • The new FileOpen macro will run only if you open a document by using any one of the following methods:
    • You click Open on the File menu.
    • You click Open on the Standard toolbar.
  • The new FileOpen macro will not run if you open a document by using any one of the following methods:
    • You open the document in Windows Explorer.
    • You open the document from the most recently used (MRU) file list.

Modification Type:MajorLast Reviewed:3/23/2006
Keywords:kbopenfile kbProgramming kbAutomation KbVBA kbhowto KB893672 kbAudEndUser kbAudDeveloper