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

x
?
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
Medium Priority
?
41 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

886 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