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
22 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lotus Notes - Open specific view in frameset (right side) 2 269
IBM Lotus notes 9 106
Why the url within notes is no action 6 62
problem with deleted user 14 56
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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