How to save password for database - mailmerge macro writer libre office

when I run a mailmerge writer macro I have to set the password for the database, otherwise i get an error. When I open a writer template that also access the database I get a dialog to enter the database password. Then the macro works.
But is there a way to store the password directly in the mailmerge macro or in the settings of libreoffice, so that i do not have to enter it every time again?

DIM aProps() as object

oMailMerge = createunoservice(“”)

oMailMerge.DataSourceName = “postgres”

Maybe something like - oMailMerge.DataSource.Password = “password”? This does not work.

Message: Couldn’t establish database connection to ‘sdbc:postgresql:postgresql://localhost:5432/postgres’
fe_sendauth: no password supplied

Thanks for your reply!


It is not recommended to bypass database security. With your request, no matter how it is achieved, it is nothing more than opening the door to access your database.

With that said, you can add the user name and password onto the Base .odb connection string (or alternatively to the Base content.xml file).

See the answers and comments in these posts:

How to store password for MySQL

Standalone Form with non-embedded database

Have just tested adding to connection string:


with PostgreSQL connection (did SDBC, JDBC and ODBC). Then creating labels from a writer document. There was no login required. Also note, there is no login required in the Base file either or anywhere else the connection is made to this Base file.

As with all questions, if this answers your question please tick the :heavy_check_mark: (upper left area of answer). It helps others to know there was an accepted answer.

FYI - Spent a number of hours trying to get Mail Merge to accept user, PW info. Got to a point of a successful result set but when it came time to send the email LO crashes consistently.

thank you.

It is now possible to connect without exposing the password etc. to the user.