Step 7. Password Protect the Document

INT012 - Create Excel Document with Template and Formatting

In this step you will protect the document using the PROTECT and PASSWORD parameters on the SET command.

1.  Right before the comment "* Save to Excel file" add PROTECT and PASSWORD parameters to your SET command. Your code should look like the following: 

* Password protect the Excel file

#jsmxcmd := 'SET OBJECT(*SHEET) PASSWORD(LANSA) PROTECT(*YES)'

USE BUILTIN(jsmx_command) WITH_ARGS(#jsmxhdle1 #jsmxcmd) TO_GET(#jsmsts #jsmmsg)

EXECUTE SUBROUTINE(CHECK_STS) WITH_PARMS(#jsmxhdle1)

2.  Compile function iiiFN13 and retest it. If you try to change the Excel document you will now see the following:

 

     You have completed this exercise. If you have time available, try to make other format changes to your Excel Document.