Solved

VBA how to embed a rich text item such as a file at the start of a rich text document body

Posted on 2016-10-04
2
17 Views
Last Modified: 2016-10-21
Could someone please help (Lotus Notes 6.5.6). The following code extract works but it puts the file at the bottom. I want it to appear at the top of whatever is in "RTFItems". I am thinking I need to somehow create a temp file to embed my file, then embed the  RTFItems and then copy the temp file back into RTFItems doc.

Dim db As Object
Dim doc As Object
...

Set Body = doc.GetFirstItem("RTFItems")

Call Body.AddNewLine(2)
Call Body.EmbedObject(1454, "", "H:\Temp\" & msgNewName, "Attachment")
...
Call doc.Save(True, False)
Kill "H:\Temp\" & msgNewName
0
Comment
Question by:Simmo Lane
2 Comments
 

Accepted Solution

by:
Simmo Lane earned 0 total points
ID: 41829237
I think I worked it out. At least it appears to be working...

                'create temp holder called TempSL
                Dim objectSL As Object
                Set objectSL = doc.CreateRichTextItem("TempSL")
               
                'Embed file into temp holder
                Call objectSL.AddNewLine(1)
                Call objectSL.EmbedObject(1454, "", "H:\Temp\" & msgNewName, "Attachment")
                Call objectSL.AddNewLine(1)
               
                'Append original content to end of temp holder
                Call objectSL.AppendRTItem(Body)
               
                'clear body of doc by deleting and recreating a blank one
                Call Body.Remove("RTFItems")
                Set Body = doc.CreateRichTextItem("RTFItems")
               
                'append the entire content of temp holder (the file and original content) into the new blank body
                Call Body.AppendRTItem(objectSL)
               
                'cleanup
                Call objectSL.Remove("TempSL")
1
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 41829421
Good show!

It should be possible using a NotesRichTextNavigator. Exactly how I don't know.

And see this article that presents a solution much like yours:
https://www-10.lotus.com/ldd/ddwiki.nsf/dx/Inserting_text_at_the_beginning_of_a_NotesRichTextItem_
It uses CopyItem to create a temp item, then removes the original Body field, creates a new one, adds new stuff and then adds the original content.

It boils down to the same, virtually...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

914 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

15 Experts available now in Live!

Get 1:1 Help Now