Microsoft KB Archive/893672

From BetaArchive Wiki

Article ID: 893672

Article Last Modified on 1/26/2007



APPLIES TO

  • Microsoft Office Word 2007
  • Microsoft Office Word 2003
  • Microsoft Word 2002 Standard Edition



INTRODUCTION

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

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.


Note In Word 2007, click the Microsoft Office Button, and then click Open.

  1. In the Open dialog box, click to select the file that you want to open.
  2. 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. In Word 2007, click Macros on the Developer tab. In Word 2003, point to Macro on the Tools menu, 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).

    Note In Word 2007, click Normal.dotm (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.



Additional query words: word2003 word2002 wd2003 wd2002 wd2k3 wd2k2 WD2007

Keywords: kbopenfile kbprogramming kbautomation kbvba kbhowto KB893672