Attached PDFs in an Item field

I have a database of docs that have PDFs attached. When I look at the docs via the forms, I see the PDFs in a field defined as Rich Text. They were placed there manually by the users.

I now have to accomplish the same thing programmatically. I create the document and set other Items to text values, but when I attach the PDFs using the AppendItemValue method of the Document object, they are displayed at the bottom of the form. How do I get the attachments into the Rich Text field like my users expect?

Here’s code:

Set objNotesDocument = objNotesDB.CreateDocument

objNotesDocument.AppendItemValue “Form”, “Contract Index”

                        objNotesDocument.AppendItemValue "Author", "Information Systems"

                        objNotesDocument.AppendItemValue "Contract_Code", strContractCode

                        objNotesDocument.AppendItemValue "Contract_Company_Code", strCompanyCode

                        objNotesDocument.AppendItemValue "Contract_Year", strYear

Set objNotesRTItem = objNotesDocument.CreateRichTextItem(“XYZ.pdf”)

Set objNotesEmbeddedObject = objNotesRTItem.EmbedObject(EMBED_ATTACHMENT, “”, objPDF_File)

objNotesDocument.AppendItemValue "Contract_Image", objNotesRTItem

Markb

Subject: Attached PDFs in an Item field

What is the purpose of the last line of your code? You already have created a richtext item to which you’ve attached the file.

Subject: RE: Attached PDFs in an Item field

When viewed via the form, the attachments are displayed within the Contract_Image field. That’s where my clients expect the attached PDFs to appear. I can attach them manually by selecting Edit from the Actions menu, selecting the field, selecting Attach from the File menu, and selecting a file off the storage device. Can I get the same result programmatically?

Subject: RE: Attached PDFs in an Item field

The problem was that I was creating the Rich Text Item with the wrong name. Here’s the solution:

Set objNotesRTItem = objNotesDocument.CreateRichTextItem(“Contract_Image”)

…where Contract_Image is the name of the Form Field.

Here’s the original code for comparison:

Set objNotesRTItem = objNotesDocument.CreateRichTextItem(“XYZ.pdf”)

There is no XYZ.pdf field on the form, so the PDF file was being displayed off the form (in some background area?)

The PDF file is now bound to the Contract_Image field when I open the doc in the form.