Article Details
Id:11139
Product:finPOWER Connect
Type:NEW
Version:1.06.08
Opened:08/05/2013
Closed:08/05/2013
Released:28/05/2013
Job: J011570

Documents; How to modify a Word VBA document to produce one document per Account when printed via Report Explorer

Documents can be configured to run either via Logs (e.g., from the Create Document page of the Accounts form) and/ or from the Report Explorer.

When run from the Report Explorer, the User is prompted with a series of parameters, e.g., Account filters which are then passed to the VBA code. The VBA code can then generate a recordset of Accounts and generate documents accordingly.

By default, all VBA templates have a constant named 'NumberOfLettersPerSavedDocument'. This determines, when printing combined letters (e.g., letters for several Accounts), how many letters should be generated before creating a new Word document.

If, when printing a Document from the Report Explorer (in what we refer to as either 'Stand-alone' or 'Ad-hoc' mode), you wish to ensure that one Word document is generated per Account then you can set this constant to 1 in the VBA.

The following example modifies the supplied Account Advice VBA to add a line to do just this (the 'Open Standalone Recordset' line is included to show where the modification should be made):

' Ensure 1 document per Account
NumberOfLettersPerSavedDocument = 1

' Open Standalone Recordset
If mDatabase.RecordsetOpen(sqb.GetSql(), rst) Then

This will still save the Word documents into the /Bulk Document Manager folder. To change this, make the following change to the SaveDocument function in the VBA code:

If mLogs Is Nothing Then
  ' Ad-Hoc (not published via a Log)
  'FileName = mfinBL.DocumentManagerFunctions.CreateUniqueFileName(BaseName, "Account", "", AccountType, mLogDocumentFileName)
  FileName = mfinBL.DocumentManagerFunctions.CreateUniqueFileName(BaseName, "Account", mAccount.AccountId, AccountType, mLogDocumentFileName)