Changing RTF fonts etc - duplicate fields problem

I have some code (posted below) which we use to make sure all our documents are in the correct font etc.

However I have just found out that the code doesn’t work if the RTF is over 64K (in which case Notes splits the information and creates a second field of the same name). In this instance only the text in the first instance is changed.

Can anyone help me amend my code, please …

Thanks

Paul

Dim session As New notessession

Dim doc As NotesDocument

Set doc = Source.Document

Dim item As NotesItem

Dim itemType As Integer

Dim body As NotesRichTextItem	

Dim nav As NotesRichTextNavigator

Dim range As NotesRichTextRange	

Dim mmfontsize As NotesRichTextStyle	

Set mmfontsize = session.CreateRichTextStyle

Dim mmfontface As NotesRichTextStyle	

Set mmfontface = session.CreateRichTextStyle

Dim mmfontul As NotesRichTextStyle	

Set mmfontul = session.CreateRichTextStyle

Dim rts As NotesRichTextSection	

Forall items In doc.Items

	If items.Type = 1 Then

		Set body = doc.GetFirstItem(items.Name)

		Set nav = body.CreateNavigator

		Set range = body.CreateRange

		mmfontsize.FontSize = 9

		mmfontface.NotesFont = body.GetNotesFont("Arial",True)

		mmfontul.Underline = False

’ go through section headings

		If nav.FindFirstElement(RTELEM_TYPE_SECTION) Then

			Set range = body.CreateRange

			Do

				Set rts = nav.GetElement

				If rts.TitleStyle.Underline = True Then

					Call rts.SetTitleStyle(mmfontul)

					Call rts.SetTitleStyle(mmfontsize)				

					Call rts.SetTitleStyle(mmfontface)

				End If					

				If rts.TitleStyle.FontSize > 9 Then

					Call rts.SetTitleStyle(mmfontsize)

					Call rts.SetTitleStyle(mmfontface)

				End If

				If rts.TitleStyle.NotesFont <> body.GetNotesFont("Arial",True) Then

					Call rts.SetTitleStyle(mmfontsize)						

					Call rts.SetTitleStyle(mmfontface)

				End If				

			Loop While nav.FindNextElement(RTELEM_TYPE_SECTION)

		End If

’ go through text runs

		If nav.FindFirstElement(RTELEM_TYPE_TEXTRUN) Then

			Set range = body.CreateRange

			Do

				range.SetBegin nav

				range.SetEnd nav

				If range.Style.FontSize > 9 Then

					Call range.SetStyle(mmfontsize)

				End If

				If range.Style.NotesFont <> body.GetNotesFont("Arial",True) Then

					Call range.SetStyle(mmfontface)

				End If

				If range.Style.Underline = True Then

					Call range.SetStyle(mmfontul)

				End If

			Loop While nav.FindNextElement(RTELEM_TYPE_TEXTRUN)

		End If

	End If

End Forall

Call doc.Save(True,True)

Subject: Changing RTF fonts etc - duplicate fields problem

You are using doc.GetFirstItem and this is what the designer’s help say about it:

If multiple items in a document have the same name, programmatic access is limited to the first item. The remaining items yield invalid data. A work-around is to get the first item, process it, remove it, again get the first item (which was the second item), and so on until you process all the items with the same name. If you do not save the document, the items are not actually removed. However, the recommendation is that you avoid creating multiple items with the same name.

Subject: RE: Changing RTF fonts etc - duplicate fields problem

Rob

Thanks for that. Great isn’t it - Notes say you shouldn’t create multiple items with the same name and then what do they do - create multiple items with the same name !!

Thanks

Paul