How do I change the text color in an existing field??? (v4.6)

Through script, how do you change the text color of an existing field in an existing document?

I have experimented with 'NotesRichTextItem' and 'NotesRichTextStyle' but to no avail.  Can someone please provide me with a quick snippet of code that will accomplish this?

Here is my code which doesn't work.  What I am trying to do here is change a field's text color to red as soon as the field is entered in edit mode.

Sub Entering(Source As Field)
 Dim workspace As New NotesUIWorkspace
 Dim session As New NotesSession  
 Dim uidoc As NotesUIDocument
 Set uidoc = workspace.CurrentDocument
 Set doc = uidoc.Document
 myfield = uidoc.CurrentField
 Dim richStyle As NotesRichTextStyle
 Set richStyle = session.CreateRichTextStyle
 Dim richText As New NotesRichTextItem(doc, myfield)
 richStyle.NotesColor = COLOR_RED
 Call richText.AppendStyle(richStyle)
 Call doc.save(True, False)
End Sub

Please help!
need_help
need_helpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

need_helpAuthor Commented:
Edited text of question.
0
ArunkumarCommented:
Hi Need Help !

The thing is after appendstyle you should append the text that will have all the qualities you set.

If you want double colour you should again create a new style, appendstyle and then append text to the richtextitem.

Good Luck !

-Arun




    Set session = New notessession
    Set maildoc = session.currentdatabase.CreateDocument
    Set richstyle = session.CreateRichTextStyle( )
    Set rtitem = New NotesRichTextItem( maildoc , "Body" )    
     
    richStyle.NotesColor = COLOR_DARK_RED
    richStyle.NotesFont = FONT_COURIER
    richStyle.FontSize = 14
    richStyle.Bold = True
     
    Call rtitem.AppendStyle(richStyle)
    Call rtitem.AppendText("<TEXT>")
    Call rtitem.AddNewLine( 2 )
    Call rtitem.AppendText("Number of documents modified --  " & modcount  )

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
need_helpAuthor Commented:
Arun,
In your example you are creating a new document.  Will this also work for an existing document?  I already tried to 'appendText' after 'appendstyle' but what happens is my existing field value gets cleared out...

Thanx again.
need_help
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

ArunkumarCommented:
Create a New RichTextItem and then

Try AppentRTItem to the existing item.

The new RTItem will have the color and font settings.

Good Luck

-Arun
0
need_helpAuthor Commented:
Arun,
What I really want to do is change the field's color but keep the field as a number data type.  I can manually change the color to, say, red and keep the field a number data type - but is there any way to do this in notes script?
0
ArunkumarCommented:
Hi !

No You cannot do that.  Any field other than richtext can have the color decided at the design time and not at run time.

Only RichText has this option of changing the color and font during run time.

If you are going to switch between two colors for two values create two fields of different colors and hide/show them accordingly.

Good Luck !

-Arun

0
need_helpAuthor Commented:
Thanx for the (bad) news.  I was hoping there was an easy way to do this, but I guess there's not.  Oh well!

need_help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.