Letter formatting problem

My query is : Basically this application generates MS Word letters by making use of a Third Party product named Intelli-print. The format of these letters is not good.

Example :

Dear Mr Ravi



I refer to your conversation/letter of/dated ….. which is now receiving our attention.





I am sorry you have found the need to raise a complaint with the Bank. My understanding

of the issues you have mentioned are as follows:



•	

•	



The points you have raised in your conversation/letter will be investigated by one of our



complaint handlers who will write to you when the investigation is complete.



The Financial Services Authority requires me to explain that after four weeks we shall



inform you in writing of the progress of your complaint. However if the investigation is not

complete within two months we will write to you again setting out the action available to



you.



I have enclosed for your information a copy of the Bank’s Complaints procedure



‘Addressing your Complaint’.  The enclosed brochure explains how to pursue your

complaint within the Bank if you remain dissatisfied; and how to refer your complaint to



the Financial Ombudsman Service if the bank cannot resolve the complaint to your



satisfaction.



We will be in touch in due course.





Yours sincerely



Ravi

Complaints Manager - Insurance 

Agent Name : Process Mail Merge :

Options :

Option Public

Option Declare

Use “LibMailMerge”

Sub Initialize

' ****************************************************************************************

' Author:				Unknown

' Creation Date:	Uinknown

'

' Revisions:

' 29-Jun-2007		0001		CJS	Bug fix as a result of NAGs SP2 build.

'

' Description:

' 

' ****************************************************************************************

Dim ws As New notesUIWorkspace                          ' Obtain Front- end object

Dim session As New notesSession                            ' Obtain Back-end object

Dim db As NotesDatabase

Dim dcSelected As notesDocumentCollection           'Collection of documents for processing from view



On Error Goto errSub

Set db = session.currentDatabase     





 ' Check for IntelliPRINT

If Not checkIntelliPRINT() Then

      'Not found - Display error msg...

	Messagebox "An IntelliPRINT installation is required to execute this feature and it is not installed in this system. Cannot proceed.", 0, db.Title

	Exit Sub

End If

Set dcSelected = db.UnprocessedDocuments

Call executeMailMerge(dcSelected)

Exit Sub

errSub:

Msgbox Erl & " : " & Err & " - " & Error$

Exit Sub

End Sub

Script library name : Execute Mail Merge :

Function executeMailMerge(dcContacts As NotesDocumentCollection) As Integer

Const PARAM_MSG_SLDIALOG = "Select standard letter"

Const PARAM_FORM_DLGMAILER = "DlgMailer"

Const FLD_UNID = "UNID"



Dim ws As New NotesUIWorkspace                       

Dim session As New notesSession                            ' Obtain Back-end object

Dim db As NotesDatabase



Dim CurrentNote As NotesDocument                         'Temporary document for dynamic user input

Dim ContactNote As notesDocument                         'Selected person document

Dim MailerNote As notesDocument                            'Selected mailer document

Dim IHandle As Long                                                 ' IntelliPRINT variables

Dim szID As String

Dim strFilePath As String

Dim iCount As Integer

Dim lnReturn As Long





On Error Goto errFunction

executeMailMerge = False



If dcContacts.Count = PARAM_ZERO Then

      'Not found - Display error msg...

	Messagebox "No documents selected for mail merge. Cannot proceed.", 0, db.Title

	Exit Function

End If



 ' Check for IntelliPRINT

If Not checkIntelliPRINT() Then

      'Not found - Display error msg...

	Messagebox "An IntelliPRINT installation is required to execute this feature and it is not installed in this system. Cannot proceed.", 0, db.Title

	Exit Function

End If



Set db = session.currentDatabase

Set CurrentNote = New NotesDocument(db)            'Create temporary document for dialog box function

If Not ws.DialogBox( PARAM_FORM_DLGMAILER, True, True, False, False, False, False, PARAM_MSG_SLDIALOG, CurrentNote ) Then

	Exit Function

End If



If CurrentNote.GetItemValue(FLD_UNID)(0) = "" Then              'User made no selection

	Msgbox "No mailer is selected from the list", MB_ICONINFORMATION,"IntelliPRINT"  

	Exit Function

End If



Set MailerNote = db.getDocumentByUNID(CurrentNote.GetItemValue(FLD_UNID)(0))     'Obtain mailer doc selected by user



Set ContactNote = dcContacts.getFirstDocument

While Not ContactNote Is Nothing

	Call UpdateDoc(ContactNote, MailerNote)                                                        ' Merge mailer fields

	szid = szid + ContactNote.noteid + ";"                                                 ' Set string of noteids for IntelliPRINT call

	Set ContactNote = dcContacts.getNextDocument(ContactNote)

Wend

’ IntelliPRINT processing

IHandle = IPSInitialize(db.Server, db.FilePath, PARAM_VIEW_NAME)   'Initialize IntelliPrint and get its Handle

Call IPSOpenFormat (IHandle,PARAM_FORMATNAME,  0 , "", "")                 'Open  format



 ' Generate the automated filename for the rtf file to be exported



strFilePath = Session.GetEnvironmentString("Directory", True) + "\TempLetter.rtf"



 ' Export the mail merged letter to a rtf file

lnReturn =  IPSExport(IHandle, szID, strFilePath, 8)

'-----------------------------------------------------OLD Code

’ iCount = 1

’ Do

’ strFilePath = Session.GetEnvironmentString(“Directory”, True) + “\Letters” & iCount & “.rtf”

’ iCount = iCount + 1

’ Loop Until Dir$(strFilePath) = “”

 ' Export the mail merged letter to a rtf file

’ lnReturn = IPSExport(IHandle, szID, strFilePath, 8)

Call IPSCloseFormat(IHandle)         'Close the format

Call IPSTerminate (IHandle)            'Terminate IP



 'Remove fields added for mail merge

Set ContactNote = dcContacts.getFirstDocument

While Not ContactNote Is Nothing

	Call RestoreDoc(ContactNote, MailerNote.Subject(0))                                       'Remove merged fields

	Set ContactNote = dcContacts.GetNextDocument(ContactNote) 

Wend



Call OpenFileinWord(strFilePath)

executeMailMerge = True     

Exit Function

errFunction:

Msgbox Erl & " - " & Err & " : " + Error$

Exit Function

End Function

Check Intelii print :

Function checkIntelliPRINT() As Integer

Dim strIPFile As String



strIPFile = "NIPRINT.dll"      ' IntelliPRINT core dll



If Dir$(strIPFile) = "" Then       ' Check whether the core dll is installed in notes program folder and set the flag accordingly.

	checkIntelliPRINT = False

Else

	checkIntelliPRINT = True

End If

End Function

Update docs:

Sub updateDoc (pdoc As notesDocument, mailerDoc As notesDocument)

’ Add Body fields

pdoc.Body = mailerDoc.LetterBody(0)

pdoc.TodayString = Format$(Today,"dd mmmm yyyy")

Call pdoc.Save( False, True )     

End Sub

Restore Doc’s

Sub restoreDoc (pDoc As notesDocument, Byval strMailSubject As String)

Dim Session As New NotesSession

Dim strLog As String

Dim vLog As Variant

'Remove Body and Salutation

pdoc.removeItem("Body")

pdoc.removeItem("TodayString")



 ' Update Case Management Log

strLog = strMailSubject + " CREATED - ( " + Session.CommonUserName + " "  & Now & " ) "



vLog = pdoc.GetItemValue("dispLetterInfo")

Redim Preserve vLog(Ubound(vLog) + 1)

vLog(Ubound(vLog)) = strLog

pdoc.dispLetterInfo = vLog



 ' Save document

Call pdoc.Save( False, True )

End Sub

Open Fileword:

Sub openFileinWord(strFilePath)

Const PARAM_WINDOW_NORMAL = 0

Const PARAM_WINDOW_MAXIMIZE = 1

Dim MyWord As Variant



 ' Open the exported rtf file in MS Word

Set Myword = CreateObject("Word.Application")

Myword.visible = True

If Myword.Application.WindowState = PARAM_WINDOW_NORMAL Then 

	Myword.Application.WindowState = PARAM_WINDOW_MAXIMIZE

End If

Myword.Documents.Open strFilePath

End Sub

Functions – Set Notes Program :

getNotesdir:

Function getNotesDir() As String

Dim sBuffer As String



Dim sChar As String

Dim sDir As String



Dim nIndex As Integer



Dim bExit As Integer



Const MAX_LEN = 127



sBuffer = String$(MAX_LEN, 0)



Call OSGetExecutableDirectory(sBuffer)



nIndex = 1

sDir = ""



bExit = False	

While Not bExit

	sChar = Mid$(sBuffer, nIndex, 1)

	

	If nIndex <= MAX_LEN And sChar <> Chr$(0) Then

		sDir = sDir + sChar

		nIndex = nIndex + 1

	Else

		bExit = True

	End If

Wend



GetNotesDir = sDir

End Function

Sub setNotesProgramDirectory()

Dim sDir As String



sDir = getNotesDir()



Chdrive Left$(sDir, 1)

Chdir sDir

End Sub

setNotesProgramDirectory :

Sub setNotesProgramDirectory()

Dim sDir As String



sDir = getNotesDir()



Chdrive Left$(sDir, 1)

Chdir sDir

End Sub

I need this type of format.

Ref : GCI/21344 12thNov2007,

												Bangalore.

Mr.T.Sangha,

17,Bangalore,

UK.

Dear T Sangha2,

I refer to your conversation/letter of/dated which is now receiving our attention. I am sorry you have found the need to raise a complaint with the Bank. My Understanding if the issues you have mentioned are as follows :The points you have raised in your conversation/letter will be investigated by one of our Complaint handlers who will write to you when the investigation is complete.

The Financial Services Authority requires me to explain that after four weeks we shall  inform you in writing of the progress of your complaint. However if the investigation is not complete within two months we will write to you again setting out the action available to you I have enclosed for your information a copy of the Bank’s Complaints

procedure Addressing your Complaint.The enclosed brochure explains how to pursue your complaint within the Bank if you remain dissatisfied; and how to refer your complaint to the Financial Ombudsman Service if the bank cannot resolve the complaint to your satisfaction. We will be in touch in due course.

The Financial Services Authority requires me to explain that after four weeks we shall inform you in writing of the progress of your complaint. However if the investigation is not complete within two months we will write to you again setting out the action available to you I have enclosed for your information a copy of the Bank’s Complaints procedure Addressing your Complaint’. The enclosed brochure explains how to pursue your complaint within the Bank if you remain dissatisfied; and how to refer your complaint to the Financial Ombudsman Service if the bank cannot resolve the complaint to your satisfaction. We will be in touch in due course.

The Financial Services Authority requires me to explain that after four weeks we shall inform you in writing of the progress of your complaint. However if the investigation is not complete within two months we will write to you again setting out the action available to you I have enclosed for your information a copy of the Bank’s Complaints procedure Addressing your Complaint’. The enclosed brochure explains how to pursue your complaint within the Bank if you remain dissatisfied; and how to refer your complaint to the Financial Ombudsman Service if the bank cannot resolve the complaint to your satisfaction. We will be in touch in due course.

The Financial Services Authority requires me to explain that after four weeks we shall inform you in writing of the progress of your complaint. However if the investigation is not complete within two months we will write to you again setting out the action available to you I have enclosed for your information a copy of the Bank’s Complaints procedure Addressing your Complaint’. The enclosed brochure explains how to pursue your complaint within the Bank if you remain dissatisfied; and how to refer your complaint to the Financial Ombudsman Service if the bank cannot resolve the complaint to your satisfaction. We will be in touch in due course.

Yours sincerely

Ravi

General Manager - Insurance

Subject: letter formatting problem

I hate to simply suggest a different third party product, but why don’t you try a free evaluation of our Midas Rich Text LSX, which is known for its rendering capabilities? If it doesn’t do a far better job, don’t bother to buy it.

On the other hand, nothing you are doing sounds like it should require much, so it is hard to see why Intelliprint doesn’t work in this scenario. You should raise the issue with Intelliprint support, I would imagine.