Subscript out of Range Error

Hello All,

I have a block of LotusScript that is throwing a “Subscript out of range” error on the line that reads:

Call rtItem.Appendtext(Title(1))

The button code is used to populate the users signature upon clicking the button that the code is run from and pulls in their title from our address books “Title” field in their person document. Everything else works as expected if I remove that one line. Any assistance would be greatly appreciated. Thank you in advance

Sub Click(Source As Button)

Dim sess As New NotesSession

Dim mailfile As NotesDatabase

Dim profiledoc As NotesDocument

Dim nitem As NotesItem

Dim rtitem As NotesRichTextItem

Dim stream As NotesStream

Dim mimeItem As NotesMIMEEntity

Dim header As NotesMIMEHeader

Dim child As NotesMIMEEntity

Dim fileFormat As String

Dim rtitemB As NotesRichTextItem

Dim Title As Variant

Dim myName As New NotesName(sess.EffectiveUserName)

Set mailfile = sess.Currentdatabase

Set profiledoc = mailfile.GetProfileDocument(“CalendarProfile”)

Title = Evaluate(|@NameLookup([Exhaustive];@UserName;“Title”)|)

'Create a RTF via MIME to embedd the graphic vs attacheming

Call profiledoc.RemoveItem(“Signature_Rich”)

Call profiledoc.RemoveItem(“DummyRichText”)

Call profiledoc.save(False, False) 'JUST To REFRESH

Set stream = sess.CreateStream

Call stream.Open(“M:\Drop to Sec\logo.jpg”)

Set mimeItem = profiledoc.CreateMIMEEntity(“DummyRichText”)

Set header = mimeItem.CreateHeader(“Content-Type”)

Call header.SetHeaderVal(“multipart/mixed”)

Set child = mimeItem.CreateChildEntity() 'Set childEntity = richTextItemObj.CreateChildEntity()

fileFormat = “image/jpeg” 'Other formats are “image/gif” “image/bmp”

Call child.Setcontentfrombytes(stream, fileformat, 1730)

Call stream.Close()

Call profiledoc.save(False, False) 'JUST To REFRESH

Set rtitemB = profiledoc.GetFirstItem(“DummyRichText”)

'Set rtItem = profiledoc.Createrichtextitem(“Signature_Rich”)

Set rtItem = profiledoc.CreateRichTextitem(“Signature_Rich”)

'add the rich text content

Call rtItem.Addnewline(1)

Call rtItem.Appendtext(myName.Common)

Call rtItem.Addnewline(1)

Call rtItem.Appendtext(Title(1))

Call rtItem.Addnewline(1)

Call rtItem.AppendText(“Our Company Name”)

Call rtItem.AddNewline(1)

Call rtItem.Appendtext(“Our Company Address”)

Call rtItem.Addnewline(1)

Call rtItem.Appendtext(“City State Zip”)

Call rtItem.Addnewline(1)

Call rtItem.Appendtext) (“Phone Number”)

Call rtItem.Addnewline(1)

Call rtItem.Appendtext(“Website URL”)

Call rtItem.Addnewline(1)

Set rtitemB = profiledoc.GetFirstItem(“DummyRichText”)

Call rtitem.AppendRTItem( rtitemB )

Call rtitemB.Remove()

'set enable the signature and for it to be a richt text signature

Set nitem = profiledoc.Replaceitemvalue(“SignatureOption”, “3”)

Set nitem = profiledoc.Replaceitemvalue(“EnableSignature”, “1”)

Call profiledoc.Save(True, False)

End Sub

Subject: lower bound of variant array is 0 not 1

Hi, Jonathan. By default the lower bound of a variant array returned from an Evaluate statement is 0 not 1. So in your code you should be using Title(0) to retrieve the title value from the array.