Se connecter avec Microsoft
S'identifier ou créer un compte.
Bonjour,
Sélectionnez un autre compte.
Vous avez plusieurs comptes
Choisissez le compte avec lequel vous voulez vous connecter.
Anglais
Désolé... Cet article n’est pas disponible dans votre langue.

Symptoms

When you try to programmatically open a Microsoft Word document, the document opens as a read-only document and you cannot edit the document.

When you add the code

   ReadOnly:=False

the document still opens as a read-only document.

When you open the same document using the Open command, the following message appears:

PathName should be opened as read-only unless changes to it need to be saved. Open as read-only?

You can open the document for editing by clicking Yes on the message.

Cause

This problem occurs because Visual Basic opens any document with the ReadOnlyRecommended attribute set to true as a read-only document, even if you attempt to set the ReadOnly attribute to false.

Note The following example applies to Word 2003 and 2002:

  1. Start Word, and then create a new document.

  2. On the Tools menu, click Options.

  3. In the Options dialog box, on the Security tab, click to select the Read-only recommended check box.

  4. Save the document as C:\Test.doc.

  5. Close the document.

  6. Press ALT+F11 to start the Visual Basic editor.

  7. On the Insert menu, click Module.

  8. In the Module sheet, type the following code:

    Sub Test()

    Documents.Open FileName:="C:\Test.doc", ReadOnly:=False

    End Sub
  9. Press ALT+F11 to return to Word.

  10. On the Tools menu, point to Macro, and then click Macros.

  11. In the Macro name list, click Test, and then click Run.

The document opens as a read-only document.

Workaround

To work around this problem, use the following Word Basic macro instead of the Visual Basic macro shown in step 8 of the "Cause" section of this article:

Sub Test()

WordBasic.FileOpen Name:="C:\Test.doc"

End Sub

With this macro the file can be edited after it opens.

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Besoin d’aide ?

Vous voulez plus d’options ?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Ces informations vous ont-elles été utiles ?

Qu’est-ce qui a affecté votre expérience ?
En cliquant sur Envoyer, vos commentaires seront utilisés pour améliorer les produits et services de Microsoft. Votre administrateur informatique sera en mesure de collecter ces données. Déclaration de confidentialité.

Nous vous remercions de vos commentaires.

×