Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I find something very close to what I want. I already edit something but I'm block e two situations: in password verification and send back to sheet1 if password is wrong.



sub PASSWORD

  ' Criar o diálogo
  oDialog = CreateUnoService("com.sun.star.awt.UnoControlDialog")
  oDialogModel = CreateUnoService("com.sun.star.awt.UnoControlDialogModel")
  oDialogModel.setPropertyValues( _
    Array("Height","PositionX","PositionY","Title","Width"), _
    Array(50,200,150,"Insira a sua senha",100))
  oDialog.setModel(oDialogModel)

  ' Criar a caixa de texto (oEditModel) que receberá a senha.
  oEditModel = oDialogModel.createInstance("com.sun.star.awt.UnoControlEditModel")
  oEditModel.setPropertyValues( _
    Array("EchoChar","Height","PositionX","PositionY","Width"), _
    Array(asc("*"),15,5,5,90) )
  oEditModel.EchoChar = asc("*")
  oDialogModel.insertByName("PasswordEdit",oEditModel)

  ' Criar o botão "Cancelar" e o botão "Ok"
  oOKButton = oDialogModel.createInstance("com.sun.star.awt.UnoControlButtonModel")
  oOKButton.setPropertyValues( _
    Array("DefaultButton","Height","Label","PositionX","PositionY","PushButtonType","Width"), _
    Array(True,15,"~OK",55,25,1,40))
  oDialogModel.insertByName("OkButton",oOKButton)
  oCancelButton = oDialogModel.createInstance("com.sun.star.awt.UnoControlButtonModel")
  oCancelButton.setPropertyValues( _
    Array("Height","Label","PositionX","PositionY","PushButtonType","Width"), _
    Array(15,"~Cancelar",5,25,2,40))
  oDialogModel.insertByName("CancelButton",oCancelButton)

  oSheet = ThisComponent.Sheets.getByName("sheet1")


  oDialog.setVisible(True)
  If oDialog.execute() = 1 Then AND 'I can't make password verification in here'

  MsgBox "PASSWORD ACCEPT",48,"ATENTION!"

else

  MsgBox "INVALID PASSWORD",48,"ATENTION!"

GoTo

  oSheet  'In here a need to send back to sheet1 if password is invalid'

End If

End Sub