locked
Error in accessing the Word.Document: System.Runtime.InteropServices.COMException (0x800A11FD): This method or property is not available because the document is locked for editing. at Microsoft.Office.Interop.Word.FontClass.set_Size(Single prop) RRS feed

  • Question

  • Hi,

    I am trying to edit the body of an appointment item programmatically by accessing Word.Document. I am getting the following error on an Outlook 2007 SP3 machine:

    System.Runtime.InteropServices.COMException (0x800A11FD): This method or property is not available because the document is locked for editing.
       at Microsoft.Office.Interop.Word.FontClass.set_Size(Single prop).

    May anyone please give a clue why this exception is thrown?

    Thanks in advance.


    Thanks Prasad

    Wednesday, February 25, 2015 4:49 AM

Answers

  • Using the Word object model will work with some limitations.

    Many functions won't work if they aren't appropriate for Outlook items, and they won't work if Outlook and Word aren't part of the same package. Also, Outlook 2007 has a more limited implementation of the Word object model than later versions.

    You can certainly set the font in an appointment body using the Word OM with Outlook 2010 for example. I just tested and set a body to all 14 point size.


    Ken Slovak MVP - Outlook

    • Marked as answer by Prasad U S Thursday, February 26, 2015 3:51 PM
    Wednesday, February 25, 2015 8:04 PM

All replies

  • Hello Prasad,

    What code do you use? Do you run another threads?

    Wednesday, February 25, 2015 9:54 AM
  • Appointment items use the RTF markup for bodies. I'd suggest using the RTFBody  property for customizing the font instead.
    Wednesday, February 25, 2015 2:42 PM
  • Using the Word object model will work with some limitations.

    Many functions won't work if they aren't appropriate for Outlook items, and they won't work if Outlook and Word aren't part of the same package. Also, Outlook 2007 has a more limited implementation of the Word object model than later versions.

    You can certainly set the font in an appointment body using the Word OM with Outlook 2010 for example. I just tested and set a body to all 14 point size.


    Ken Slovak MVP - Outlook

    • Marked as answer by Prasad U S Thursday, February 26, 2015 3:51 PM
    Wednesday, February 25, 2015 8:04 PM
  • When testing something it's often easiest to prototype things using the Outlook VBA project. For example, the following Outlook VBA code will format the body of an open appointment item as 16 point bold. I tested it on Outlook 2007 SP3:

    Sub FormatFont()
        Dim doc As Word.Document
        Dim f As Word.Font
       
        Set doc = Application.ActiveInspector.WordEditor
        Set f = doc.Range.Font
        f.Size = 16
        f.Bold = True
    End Sub


    Ken Slovak MVP - Outlook

    Wednesday, February 25, 2015 8:53 PM
  • Prasad,

    I don't see any possible explanation why you get an exception in the code.

    Could you please share the cause for others? Have you found it?

    Thursday, February 26, 2015 4:03 PM
  • Hi Eugene,

    I came across this exception only on Outlook 2007. When I tested the same in Outlook 2010, I didn't see this issue.


    Thanks Prasad

    Tuesday, March 3, 2015 5:08 AM