Sample CL Program for Opening Word Doc and Printing with iSeries Office Integrator - Support

Sample CL Program for Opening Word Doc and Printing with iSeries Office Integrator

From Support

Jump to: navigation, search
            PGM                                                        
                                                                        
             DCL        VAR(&RTNIP) TYPE(*CHAR) LEN(15)                 
             DCL        VAR(&SGLQUOTE) TYPE(*CHAR) LEN(3) VALUE('''')   
             DCL        VAR(&WORDDOC) TYPE(*CHAR) LEN(256)              
             DCL        VAR(&PRINTER) TYPE(*CHAR) LEN(100)              
             DCL        VAR(&CMDLINE) TYPE(*CHAR) LEN(512)              
                                                                        
             MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRORS))        
                                                                        
/*************************************************/                     
/* SEND STATUS MESSAGE TO SCREEN                 */                     
/*************************************************/                     
             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Opening +  
                          Word Document for Printing') TOPGMQ(*EXT) +   
                          MSGTYPE(*STATUS)                              
                                                                        
/*************************************************/                     
/* Build Windows Printer Name                    */                     
/* To determine correct printer name, open MS    */                     
/* Word, select File/Print and use the name that */                     
/* is displayed in the MS Word print dialog.     */                     
/* Ex: \\HP3000                                  */                     
/* The above is an example of a network printer. */                     
/*************************************************/                     
             CHGVAR     VAR(&PRINTER) VALUE('HP 2000C')                 
                                                                        
/*************************************************/                     
/* Build MS Word Document Name                   */                     
/* If your file name path contains spaces, you   */                     
/* may need to add double quotes to the file path*/                     
/* or MS Word may not open the file correctly.   */                     
/*************************************************/                     
             CHGVAR     VAR(&WORDDOC) VALUE('"C:\PROGRAM +              
                          FILES\RJSOFFICE\MERGE1.DOT"')                 
                                                                        
/*************************************************/                     
/* OPEN SELECTED WORD DOC AND PRINT IT           */                     
/*************************************************/                     
                                                                        
             /* LAUNCH MS WORD */                                       
             OFCRUNPC   RMTSYS(*CURRENT) CMD('WORDLAUNCH') +            
                          OPTION(*WORDOLE)                              
                                                                        
             /* Build WORDFILEOPENPRINT command line. 
             CHGVAR     VAR(&CMDLINE) VALUE('WORDFILEOPENPRINT~' |< +   
                          &WORDDOC |< '~' |< &PRINTER |< '~ ~ ~ ~ ~ ')  
                                                                        
             /* OPEN DOC AND PRINT IT */                                
             OFCRUNPC   RMTSYS(*CURRENT) CMD(&CMDLINE) OPTION(*WORDOLE) 
                                                                        
             /* EXIT MS WORD  */                                        
             OFCRUNPC   RMTSYS(*CURRENT) CMD(WORDEXIT) +                
                          OPTION(*WORDOLE)                              
                                                                        
/*************************************************/                     
/* SEND COMPLETION MESSAGE                       */                     
/*************************************************/                     
             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) +                  
                          MSGDTA('Document print has completed')        
                                                                        
             RETURN  /* NORMAL EXIT */                                  
                                                                        
/* GENERAL ERROR HANDLER */                                             
ERRORS:                                                                 
             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Errors +   
                          occurred while running PC command') +         
                          MSGTYPE(*ESCAPE)                              
                                                                        
             ENDPGM  

Personal tools