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
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.
- Create a macro called "PrintLetter" to set up your print specification and then call Kappris
- Edit the KapprisBeforeDialog event handler to implement the print specification
- Assign your "PrintLetter" macro to a toolbar button (if required)
Coding
Create the "PrintLetter" macro
Open the KapprisWord (or KapprisInterwoven) template in Word and go to the Visual Basic editor.
Add a module to KapprisWord and call it "General"
Create your new macro within General, together with two global variables called KapprisCategory and KapprisPrintMode
1: 2: 3: 4: 5: 6: 7: 8: |
Option Explicit Public KapprisCategory As String Public KapprisPrintMode As String Public Sub PrintLetter() End Sub |
Complete your macro as shown
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: |
Option Explicit Public KapprisCategory As String Public KapprisPrintMode As String Public Sub PrintLetter() On Error GoTo PrintLetter_Error KapprisCategory = "Correspondence" KapprisPrintMode = "Letter + Copy" WordUI.FilePrint PrintLetter_Error: KapprisCategory = "" KapprisPrintMode = "" End Sub |
Edit the KapprisBeforeDialog event handler
Find the KapprisIntegration module in KapprisWord
Find the KapprisBeforeDialog event handler within the KapprisIntegration module
Edit the event handler so as to check the KapprisCategory and KapprisPrintMode variables and use them if they are non-blank
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: |
Public Sub KapprisBeforeDialog(ByVal Kupris As Kupris.IKupris2, ByVal Job As KappSrvr.IJob, Optional ShowDialog As Boolean = True, Optional Cancel As Boolean = False) 'Occurs before the print dialog shows 'Use the ShowDialog parameter to enable/disable display of the dialog 'Use Kupris.Category = <RequiredCategory> to set a category in the dialog 'Use Kupris.PrintMode = <RequiredPrintMode> to set a print mode in the dialog 'Use Cancel = True to cancel the printing process On Error Resume Next If KapprisPrintMode <> "" Then Kupris.Category = KapprisCategory Kupris.PrintMode = KapprisPrintMode ShowDialog = False End If On Error GoTo 0 End Sub |
This code sets the Category and PrintMode of the Kupris object, which is passed as an argument to the event handler. Also, because we want to avoid displaying the print dialog, it sets the ShowDialog boolean argument to hide the dialog completely.
Completed Code Modules
The code modules General and KapprisIntegration can be found here: Cod. eModules.zip