none
how to enable/disable or lock/unlock a ContactItem's "Body" field RRS feed

  • Question

  • I'm trying to add a command button to a custom form in Outlook 2007 that will allow or disallow a user to edit the Body of the item. In the form's design mode, the control is named _DocSiteControl1 and appears to be mapped to the Body of the item. But I can't find a way to address it from VBScript that would allow me to change Lock or ReadOnly or Enable it. Any of these options would be ok, I just want to be able to switch between allowing edits and not allowing them. 

    I found some code on another site that looks like it might work in VB, but I haven't been able to get it to work in VBScript in my custom form. Maybe someone can see what it would take.

    ----------------------------------------------------------------

    ' I was able to get the Outlook Body to be read-only by casting it as an OlkControl:
    Dim olkItem As Outlook.OlkControl
    olkItem = CType(_DocSiteControl1, Outlook.OlkControl)
    olkItem.ReadOnly = True

    -----------------------------------------------------------------

    Any ideas about how to accomplish this much appreciated.

    Tuesday, January 21, 2014 2:49 PM

Answers

  • The only events that fire for controls in VBScript and custom forms is the Click event.  You're stuck with monitoring PropertyChange, unfortunately.  It looks like you need to do some advanced processing, so I strongly recommend you switch to developing a COM Add-in and use .NET controls inside a Form Region or Task Pane.  You could do far more, such as using the RichTextBox control or other 3rd party controls to render the content of the Outlook item and have the benefit of a wide range or properties and events at your disposal.

    Eric Legault (MVP: Outlook)
    About me...
    Outlook Appins: Store Social Media fields in your Outlook Contacts!

    Tuesday, January 21, 2014 4:19 PM
    Moderator

All replies

  • The OlkControls are specific to Form Regions, not the MSForms controls used in the standard form designer.

    The "Notes" control can't be disabled or locked, unfortunately.  You can see what properties are available for that control by selecting it and clicking the Advanced Properties button in the form designer.  You can hide it though - this sample just toggles the visibility:

    Sub CommandButton1_Click
        Dim objC

        Set objC = Item.GetInspector.ModifiedFormPages("General").Controls("Notes")
        objC.Visible = Not(objC.Visible)
    End Sub


    Eric Legault (MVP: Outlook)
    About me...
    Outlook Appins: Store Social Media fields in your Outlook Contacts!

    Tuesday, January 21, 2014 3:40 PM
    Moderator
  • Can you think of any event that would fire when a user enters the Notes field or starts typing in it? So I could set another field when the event fires? Or any other way to tell that the user has clicked into the field and may be changing the text?

    The PropertyUpdate event doesn't seem to fire until the user leaves the field. But if they're typing a lot, that may be a while.

    Thanks for any ideas on this.

    Tuesday, January 21, 2014 4:13 PM
  • The only events that fire for controls in VBScript and custom forms is the Click event.  You're stuck with monitoring PropertyChange, unfortunately.  It looks like you need to do some advanced processing, so I strongly recommend you switch to developing a COM Add-in and use .NET controls inside a Form Region or Task Pane.  You could do far more, such as using the RichTextBox control or other 3rd party controls to render the content of the Outlook item and have the benefit of a wide range or properties and events at your disposal.

    Eric Legault (MVP: Outlook)
    About me...
    Outlook Appins: Store Social Media fields in your Outlook Contacts!

    Tuesday, January 21, 2014 4:19 PM
    Moderator
  • Hi,

    Since we haven't heard from you for a long time, I temporarily close this case. I mark useful reply as answer. If you have any concerns, please free feel to reopen it or submit a new question.

    Thanks for your understanding.

    Best regards

    Fei 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 28, 2014 12:40 PM
    Moderator