Wiki

Case Status
Log In

Wiki

 
Writing Kappris Integration Ma…»Remove the logo for the letter…
  • RSS Feed

Last modified on 04/08/2011 15:59 by User.

Tags:

Remove the logo for the letter and put it back for the copy

Assumptions

  • You understand how to write Word VBA macros and how to work with the Word VB Editor
  • You have a print mode configured in Kappris called "Letter + Copy" that exists in the "Correspondence" category
  • You already have a HideLogo macro of your own that will hide the logo
  • You already have a ShowLogo macro of your own that will show the logo

Steps

  • Using the Kappris Print Dialog in Word, test your "Letter + Copy" print mode in the "Correspondence" category and make sure it behaves exactly as you would expect.

  • Edit the KapprisBeforeImprint event handler to add/remove the letter logo
  • Edit the KapprisAfterPrint event handler to reinstate the letter logo

Coding

Edit the KapprisBeforeImprint event handler

Open the KapprisWord (or KapprisInterwoven) template in Word and go to the Visual Basic editor.

Find the KapprisIntegration module in KapprisWord

Find the KapprisBeforeImprint event handler within the KapprisIntegration module

Edit the event handler to check the current imprint and see if it is using "Letterhead" stationery. If it is, the code should hide the logo. If it is not using "Letterhead" the code should show the logo.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Private Sub KapprisBeforeImprint(ByVal Kupris As Kupris.IKupris2, ByVal Job As KappSrvr.IJob, ByVal Index As Long, ByVal IndexWithinJob As Long, PrintNow As Boolean, CancelImprint As Boolean)
  'Occurs after an imprint's parameters have been stored in the Job but before
  'the imprint is printed
  'Use the IndexWithinJob parameter to query the Job parameters for this imprint
  'The Index parameter gives the index of this imprint in the whole print request
  'Use PrintNow to get the imprint to be printed immediately after this event handler
  On Error Resume Next
  
  Dim FPPaper As String
  Dim OPPaper As String
  
  FPPaper = GetParamValue(Job, "First Page Tray Paper[" & IndexWithinJob & "]")
  OPPaper = GetParamValue(Job, "Other Pages Tray Paper[" & IndexWithinJob & "]")
  
  If (FPPaper = "Letterhead") Or (OPPaper = "Letterhead") Then

    PrintNow = True
    
    HideLogo
    
  Else
  
    ShowLogo

  End If
  
  On Error GoTo 0
End Sub

The Kupris argument can be used to get or set information about dialog behaviour.

The Job argument can be used to get or set finely detailed information about the whole print request. Job makes available many lists of named variant values used by Kappris.

This code queries two Job parameters: "First Page Tray Paper[n]" and "Other Pages Tray Paper[n]"  to check if either is set to "Letterhead".

To do this it uses the GetParamValue helper function and the IndexWithinJob argument. The IndexWithinJob should always be used when trying to retrieve information about the imprint that is about to be printed.

On finding that Letterhead is in use for the current imprint, the event handler runs the HideLogo routine and sets PrintNow to true. PrintNow is used to force Kappris to print the current imprint immediately because the document must be printed in its current state.

On finding that Letterhead is not in use for the current imprint, the event handler runs the ShowLogo routine but does not force the current imprint to be printed immediately because Kappris will print it anyway after the last imprint has been processed.

Clearly this event handler makes assumptions about the print mode in use and the order of imprints.

Completed Code Module

The code modules General and KapprisIntegration can be found here: CodeModule.zip