Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / July 2004

Tip: Looking for answers? Try searching our database.

Notes control in Contact form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Malcolm - 20 Jul 2004 20:08 GMT
Hi,
I understand that all outlook forms share a message
control.  
For email, it's the main body.  
For contacts, it's the notes field.  
I also understand that this field is bound to the Body
property of the item.

What I am having trouble with is how to refer to this
field in VBScript or VBA.
I understand how to refer to controls in general, I just
do not know what this is called programmatically.  
If I look at Properties, I only see the one tab, and in
the contact form it says the name is 'Notes'.  
Referring to it by this name results in an error though,
because it is not the true name.

My goal is the ability to set/unset the ReadOnly property
of the field based on the clicking of a checkbox by
particular users.
<i>
Sub EditNotes_Click()
    dim MyValue, User, objPage
    User = Application.GetNameSpace
("MAPI").CurrentUser
    Set objPage = Item.GetInspector.ModifiedFormPages
("General")
    MyValue = objPage.Controls("EditNote")
    if(User = "a" Or User = "b" Or User = "c" Or User
= "d" Or User = "e") Then
        <b>objPage.Controls("Notes").ReadOnly =
MyValue</b>
    else
        if (MyValue) then  'clicked, turn back off
            objPage.Controls("EditNote") =
false
        else 'not clicked, turn back on
            objPage.Controls("EditNote") =
true
            msgbox "Turned on"
        end if
    end if
End Sub
</i
Sue Mosher [MVP-Outlook] - 20 Jul 2004 21:35 GMT
I don't think it's possible to programmatically lock that control, although
it can be done through its Properties dialog. An alternative approach would
be to hide the control for the users in question and show instead a plain
multi-line text box bound to the Notes/Message field:

   Set objPage = Item.GetInspector.ModifiedFormPages("General")
   Set Notes = objPage.Controls("Notes")
   Set TextBox1 = objPage.Controls("TextBox1")
   Notes.Visible = False
   TextBox1.Text = Item.Body
   TextBox1.Visible = True

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Hi,
> I understand that all outlook forms share a message
[quoted text clipped - 40 lines]
> End Sub
> </i
Malcolm - 20 Jul 2004 21:44 GMT
That was my next step.  Although this step would look
more like writing a script (I like to use Word VBA with
Outlook Reference for these one-time things) that goes
through 3,000 contacts and copies the Item.body over to
the textbox for the existing contacts.  Fun!  Be so much
more fun though if Outlook would dump VBscript and use
full blown VBA.  That's my only quibble.

Is it possible though to refer to the control
programmatically (even if you can't lock it)?  Just for
future reference in case something else comes along.

Thanks,
Malcolm

>-----Original Message-----
>I don't think it's possible to programmatically lock that control, although
[quoted text clipped - 55 lines]
>
>.
Sue Mosher [MVP-Outlook] - 20 Jul 2004 22:17 GMT
No, ho, no, that's not what it does at all. You would put that code in
Item_Open event handler of your custom form. In other words, the code would
run only when the user opens such an item.

The code you originally posted is correct for referring to the control if
you've renamed it EditNote.

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> That was my next step.  Although this step would look
> more like writing a script (I like to use Word VBA with
[quoted text clipped - 27 lines]
> >    TextBox1.Text = Item.Body
> >    TextBox1.Visible = True

> >"Malcolm" <anonymous@discussions.microsoft.com> wrote in
> message
[quoted text clipped - 48 lines]
> >
> >.
Malcolm - 21 Jul 2004 16:37 GMT
It's all working now, here's the final code.  I changed
the code slightly to check against user names stored in
an olNoteItem in a subfolder of the contact folder.  This
note item looks like:

Administrative:
John;
Jill;
Jack;

The controls I am using:
"Notes" = the Note/Message standard object
"EditNotes" = checkbox to lock/unlock it

Here is the code:

Sub EditNotes_Click()
    dim MyValue, curUser, objPage, Notes, i,
boolFlag, NoteCheckBox
    dim curFolder, fld, Allow_Users, User_String,
User_Position, User_Array
    curUser = Application.GetNameSpace
("MAPI").CurrentUser
    Set objPage = Item.GetInspector.ModifiedFormPages
("General")
    MyValue = objPage.Controls("EditNotes")
    Set curFolder = Item.Parent
    Set fld = curFolder.Folders("CompanyNotes")
    Set Allow_Users = fld.items("Administrative:")
    User_String = Allow_Users.body
    User_Position = instr(1, User_String, ":")
    User_String = Mid(User_String, User_Position + 1,
len(User_String))
    User_String = Replace(replace(User_String, Chr
(13) , ""), Chr(10), "")
    User_Array = Split(Cstr(User_String), ";")
    for i = 0 to Ubound(User_Array)
        if (curUser = User_Array(i)) then
            set Notes = objPage.Controls
("Notes")
            Notes.ReadOnly = Not MyValue
            boolFlag = true
            Exit For
        end if
    next
    if (Not boolFlag) then  'invalid user clicked,
make sure the checkbox is off
        set NoteCheckBox = objPage.Controls
("EditNotes")
        NoteCheckBox.Value = false
    end if
End Sub

Thanks for the help Sue!
Malcolm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.