Solved

Replacing substrings in a RichText field - possible??

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

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now