Is there a way to supply the password to a password protected file via terminal or code?

I have several documents that have the same password to open them. I would like to enter the password for each file once (ie store in code), and then have the program that I create open the files for viewing.

Thanks.

Bug fdo#42647 is the related enhancement request to get a command line option made available for passing a plain text password / passfile. I would think it more likely possible using the UNO API.