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
14 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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