Solved

Replacing substrings in a RichText field - possible??

Posted on 2002-07-26
9
635 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
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.

 

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 100 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Updating Lotus Notes workspace icons with new server 1 135
@ command if structure getting unmanageable 12 100
Domino Server 2 80
Cannot access mail archive from IBM domino 5 108
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…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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