Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Replacing substrings in a RichText field - possible??

Posted on 2002-07-26
9
Medium Priority
?
641 Views
Last Modified: 2013-12-18
Is it possible somehow - and if it is, do you know HOW - to replace a substring in a RichText field in a document?

Thanks a lot for any solution!!!

~adams
0
Comment
Question by:adamsfamily
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 9

Expert Comment

by:Arunkumar
ID: 7179779
Did you try to use the @Abstract on the RTField and then do the @ReplaceSubstring and then @SetField to set the RTField with the new value ???

-Arun

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7180584
This routine does the job, but loses all the nice rt format.

Sub Click(Source As Button)
     Dim session As New NotesSession
     Dim ws As New NotesUIWOrkspace
     Dim uidoc As NotesUIDOcument
     Dim note As NotesDocument
     Dim rt As NotesRichTextItem
     
     Set uidoc = ws.CurrentDocument
     Set note = uidoc.DOcument
     Set rt = note.GetFirstItem( "RT" )
     ret = ReplaceSubstring( rt.text, "notes", "Domino")
     Call rt.Remove
     Set rt = note.CreateRichTextItem( "RT" )
     Call rt.AppendText( ret )
     note.save True, False
End Sub


Function ReplaceSubstring( Byval s1 As String, s2 As String, s3 As String) As Variant
     Dim index%
     
     index = Instr( s1, s2 )
     If index = 0 Then
          ReplaceSubstring = s1
     Else
          ReplaceSubstring = Left$(s1, index - 1 ) & s3 & ReplaceSubstring(Right$(s1, Len(s1) - (index + Len(s2)) + 1 ), s2, s3 )
     End If
End Function


~Hemanth
0
 
LVL 3

Expert Comment

by:Joep8020
ID: 7185125
There is an article in The View from July/August 1998, dealing with using the C API to manipulate RTF.

This is an excellent resource to understand how to do what you want. By the way, you can also change colors, fonts etc. using these methods.

good luck
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:adamsfamily
ID: 7201172
Dear Hemanth,

  thanks for the code you wrote, the problem is that I would have liked to use templates for documents, that a user can edit in a rich text, and additionally he can add special strings ("fields") into the richtext and an agent should replace them with their actual value :-(
  So the formatted RichText would have been the basic of the solution. But thanks anyway.

Joep8020,

  I was afraid to use C API because of the compatibility with various Notes clients, windows versions, etc. But I'm going to have a look at it. Thanks

~adams
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7203613
Then Sorry!!! there is no other way to handle text in richtext field.

C API, could be a solution, but it is little tedious to understand it at first ?!?
0
 

Author Comment

by:adamsfamily
ID: 7220920
Hi Hemanth,

the most important thing is, the database to work securely. I've decided to use Word documents. The possibilities to manipulate with a RichText field are really poor :-(

What now? Delete the question or should I accept your comment, what's you opinion?

~adams
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 400 total points
ID: 7221060
Well here are your options.

By deleting you are going to lose the script that I provided, which might come handy some time later.

By accepting the solution, you will keep the code for future and as well increase my score in my profile, which in turn will also give you points in future if someone is interested in this question.

So choice is yours and I am happy with my current ranking. I am sure there will be some requirement similar to yours and I have a solution ready made.

Cheers
~Hemanth

PS: I notice that you too use ~ symbol in your signature. gr8
0
 

Author Comment

by:adamsfamily
ID: 7235350
I accepted a bad comment as the answer for this question.

The solution is Hemanth's script above, of course.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7239004
Unless the right person gets the credit, it is OK.

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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