WD97: Error Using Documents.Open to Open Non-Word File

Last reviewed: February 5, 1998
Article ID: Q157616
The information in this article applies to:
  • Microsoft Word 97 for Windows

SYMPTOMS

When you run the following statement,

   Documents.Open FileName:= "test", Format:= wdOpenFormatRTF

to open a file "test.rtf" you will receive the following error:

  Run-time error '5174': This file could not be found.

Or, if a file, "test.doc", exists in the same folder as "test.rtf":

  Run-time error '5121': Word cannot open this document.

CAUSE

If a file extension is not specified when using the FileName argument, Word will try to open the file assuming a .doc extension, not by what is specified in the Format argument. The Format argument does not specify the file extension or type of file to open, rather it specifies the file converter to use to open the file. In this example:

   "Format:= wdOpenFormatRTF"

opens the file using the Rich Text Format (RTF) converter.

WORKAROUND

Specify the filename and extension when using the statement:

  Documents.Open FileName:= "test.rtf", Format:= wdOpenFormatRTF

MORE INFORMATION

The same problem arises when using:

  Application.Options.DefaultOpenFormat = wdOpenFormatRTF
  Documents.Open FileName:= "test"

STATUS

Microsoft has confirmed this to be a problem in Microsoft Word 97 for Windows. Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


KBCategory: kbmacro
KBSubcategory:
Additional query words: macro debug method vba vbe visual basic word97
Keywords : kbmacro
Version : 97
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.