#include .... String aPwdTitle( RTL_CONSTASCII_USTRINGPARAM( "Document password" ) ); SfxPasswdDialog aDlg( this, &aPwdTitle ); aDlg.ShowExtras( SHOWEXTRAS_CONFIRM ); String aPassword, aConfirm; bool bCanceled = false; do { bCanceled = (aDlg.Execute() != 0); if( ! bCanceled ) { // dialog was not canceled aPassword = aDlg.GetPassword(); aConfirm = aDlg.GetConfirm(); if( ! aPassword.Len() ) { ErrorBox aBox( this, String( RTL_CONSTASCII_USTRINGPARAM( "password empty" ) ) ); aBox.Execute(); } else if( aPassword != aConfirm ) { ErrorBox.aBox( this, String( RTL_CONSTASCII_USTRINGPARAM( "password not confirmed" ) ) ); aBox.Execute(); } } } while( !bCanceled && aPassword != aConfirm ); if( ! bCanceled ) { // set new password here }