Word 2013 Bug: “Not available for reading” error on opening a document

The more people use Word 2013, the more changes and problems are bubbling to the surface. Again, this one was brought to the world’s attention in the Word for Developers forum.

“Reading mode” was introduced a few years ago to provide a more efficient way to read documents on-screen. By default, documents opened from an e-mail attachment will display in this view. As the view is optimized for reading, most editing commands are not available while in that mode. This lock-out also applies to the object model. When code tries to make modifications to the document that aren’t allowed while in reading mode, you see run-time error 4605: “This method or property is not available because this command is not available for reading”.

Of course, we don’t expect to see this error when a document is opened in a different view, such as the default Print Layout. But that’s exactly what’s happening in Word 2013 when two documents are opened, the header/footer of the second is addressed and information copied from it into the header/footer of the first document, then a method is used that affects the entire first document, rather than a specific range. A somewhat obscure combination of circumstances, but nonetheless legitimate.

In effect, it appears that the second of the two document windows being opened is being tagged as open in Reading mode after the header/footer is addressed. This is a bug.

The workaround is to add a line of code that explicitly forces the second document window into Print Layout view.

Here are the repro steps for VBA. The workaround is the line commented out. Remove the apostrophe at the beginning of the line and the code should then work as expected, with no errors.

  1. Create a new document; save as source.docs
  2. Create a new document; save it as a template as template.dotx
  3. Run the following VBA code
Sub ReadModeError()
  Dim WDApp As Word.Application
  Set WDApp = Application

  Dim Doc As Word.Document
  Set Doc = WDApp.Documents.Add("c:\test\template.dotx")
  Dim HF As Word.Document
  Set HF = WDApp.Documents.Open("c:\test\source.docx")

  'HF.ActiveWindow.View = wdPrintView 'Workaround to avoid problem

  Doc.Sections.First.Headers(wdHeaderFooterPrimary).Range.FormattedText _
    = HF.Sections.First.Headers(wdHeaderFooterPrimary).Range.FormattedText
  Doc.Sections.First.Footers(wdHeaderFooterPrimary).Range.FormattedText _
    = HF.Sections.First.Footers(wdHeaderFooterPrimary).Range.FormattedText

  HF.Saved = True

  Dim rng As Word.Range
  Set rng = Doc.Content
  rng.InsertBefore vbCrLf 'Throws the exception
  rng.Paragraphs.TabStops.ClearAll 'Also throws the exception
End Sub

7 Responses to “Word 2013 Bug: “Not available for reading” error on opening a document”

  1.   Chris Says:

    This issue seems to extend to other parts of the work document. I had the same error when referencing bookmarks, and setting to print view seems to have resolved the problem as well! Thanks

  2.   WordLearner Says:

    Help appreciated,

    Want to read header also with the file content.

    I have:

    I want to read header also what should i have that copies the text to clipboard.

    Thanks in advance for your help and support.

  3.   kewpcg Says:

    Hi Cindy, just wanted to add something about this Word 2013 “Not available for reading” problem. If you programmatically open a document that is read-only on disk, setting ReadOnly = False and Visible = False, you may still get errors when you attempt to manipulate the non-visible document because it is actually in ReadingLayout view. When you check for ActiveWindow.View.ReadingLayout, it will come back as False. And if you try to set the view to ReadingLayout= False, it does not actually work on the non-visible window. If you switch the document to visible, you will see that it is still in ReadingLayout.

    For example:

    Set oDoc = Application.Documents.Open(FileName:=strDocPath, ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, Visible:=False)

    ‘Watch out – if the document is read-only on disk, and opened non-visible, the below code does not affect the document view.
    If oDoc.ActiveWindow.View.ReadingLayout then
    oDoc.ActiveWindow.View.ReadingLayout = False
    end if

    The workaround in my case is to make sure the document is not read-only on disk. But you could also set the active window to Visible temporarily just while you access the ReadingLayout property, and then change it back to non-Visible.

    Just thought I’d share my findings in case it helps anyone else.

    •   WordMeister Says:

      Thank you for sharing :-)
      Sorry about the delayed approval – WordPress hasn’t been notifying me about new comments…

Leave a Reply