Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
33 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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