?
Solved

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

Posted on 1999-11-10
7
Medium Priority
?
294 Views
Last Modified: 2013-12-18
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
0
Comment
Question by:need_help
  • 4
  • 3
7 Comments
 

Author Comment

by:need_help
ID: 2197519
Edited text of question.
0
 
LVL 9

Accepted Solution

by:
Arunkumar earned 120 total points
ID: 2197539
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
 

Author Comment

by:need_help
ID: 2197962
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 9

Expert Comment

by:Arunkumar
ID: 2197978
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
 

Author Comment

by:need_help
ID: 2198661
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
 
LVL 9

Expert Comment

by:Arunkumar
ID: 2198694
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
 

Author Comment

by:need_help
ID: 2198720
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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question