need_help
asked on
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.CreateRichTextStyl e
Dim richText As New NotesRichTextItem(doc, myfield)
richStyle.NotesColor = COLOR_RED
Call richText.AppendStyle(richS tyle)
Call doc.save(True, False)
End Sub
Please help!
need_help
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.CreateRichTextStyl
Dim richText As New NotesRichTextItem(doc, myfield)
richStyle.NotesColor = COLOR_RED
Call richText.AppendStyle(richS
Call doc.save(True, False)
End Sub
Please help!
need_help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
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
Try AppentRTItem to the existing item.
The new RTItem will have the color and font settings.
Good Luck
-Arun
ASKER
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?
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?
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
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
ASKER
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
need_help
ASKER