Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Replacing substrings in a RichText field - possible??

Posted on 2002-07-26
9
Medium Priority
?
642 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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

876 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