Boa tarde a todos do forum,
Pessoal após estar finalizando minha plan , obtive um erro , com 2 forms , quando tento executa-la tenho a mensagem de erro 424, objeto não encontrado ,
alguém tem alguma idea
Const nome = 1
Const senha = 2
Const nivel = 3
Const gestor = 5
Const gestorsenha = 6
Private Sub btAlterar_Click()
' Usuario
If OptUsuario.Value Then
pergunta = MsgBox("Deseja alterar os dados?", vbExclamation + vbYesNo, "")
If pergunta = vbNo Then
Exit Sub
End If
lin = 3
Do Until Sheets("Login").Cells(lin, nome) = ""
If cdnome = Sheets("Login").Cells(lin, nome) Then
Sheets("Login").Cells(lin, nome) = cdnome
Sheets("Login").Cells(lin, senha) = cdSenha
Sheets("Login").Cells(lin, nivel) = cdNivel
End If
lin = lin + 1
Loop
'...................................................................
'limpar
lsLista.ListItems.Clear
lastRow = Plan3.Cells(Plan3.Cells.Rows.Count, "a").End(xlUp).Row
' Adiciona itens
For x = 3 To lastRow
Set li = lsLista.ListItems.Add(Text:=Plan3.Cells(x, "a").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "b").Value
li.ListSubItems.Add Text:=Plan3.Cells(x, "c").Value
Next
ActiveWorkbook.Save
End If
'Gestor
If OptGestor.Value Then
pergunta = MsgBox("Deseja alterar a senha do Gestor?", vbExclamation + vbYesNo, "")
If pergunta = vbNo Then
Exit Sub
End If
lin = 3
Do Until Sheets("Login").Cells(lin, gestor) = ""
If cdnome = Sheets("Login").Cells(lin, gestor) Then
Sheets("Login").Cells(lin, gestor) = cdnome
Sheets("Login").Cells(lin, gestorsenha) = cdSenha
End If
lin = lin + 1
Loop
'...................................................................
'limpar
lsListaGestor.ListItems.Clear
lastRow = Plan3.Cells(Plan3.Cells.Rows.Count, "e").End(xlUp).Row
' Adiciona itens
For x = 3 To lastRow
Set li = lsListaGestor.ListItems.Add(Text:=Plan3.Cells(x, "e").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "f").Value
Next
ActiveWorkbook.Save
End If
End Sub
Private Sub btInserir_Click()
' Usuario
If OptUsuario.Value Then
lin = 3
Do Until Sheets("Login").Cells(lin, nome) = ""
If cdnome = Sheets("Login").Cells(lin, nome) Then
MsgBox "Nome já cadastrado! Por favor Verifique.", vbCritical, ""
cdnome.SetFocus
Exit Sub
End If
If cdnome = "" Or cdSenha = "" Or cdNivel = "" Then
MsgBox "Campos obrigatórios não preenchidos! Por favor Verifique.", vbCritical, ""
Exit Sub
End If
lin = lin + 1
Loop
Sheets("Login").Cells(lin, nome) = cdnome
Sheets("Login").Cells(lin, senha) = cdSenha
Sheets("Login").Cells(lin, nivel) = cdNivel
'...................................................................
'limpar
lsLista.ListItems.Clear
lastRow = Plan3.Cells(Plan3.Cells.Rows.Count, "a").End(xlUp).Row
' Adiciona itens
For x = 3 To lastRow
Set li = lsLista.ListItems.Add(Text:=Plan3.Cells(x, "a").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "b").Value
li.ListSubItems.Add Text:=Plan3.Cells(x, "c").Value
Next
ActiveWorkbook.Save
MsgBox "Usuário Cadastrado com Sucesso.", vbInformation, ""
Call LimparCampos
'Habilita
OptGestor.Enabled = True
OptGestor.Value = False
OptUsuario.Enabled = True
OptUsuario.Value = False
End If
'Gestor
If OptGestor.Value Then
lin = 3
Do Until Sheets("Login").Cells(lin, gestor) = ""
If cdnome = Sheets("Login").Cells(lin, gestor) Then
MsgBox "Nome já cadastrado! Por favor Verifique.", vbCritical, ""
cdnome.SetFocus
Exit Sub
End If
If cdnome = "" Or cdSenha = "" Then
MsgBox "Campos obrigatórios não preenchidos! Por favor Verifique.", vbCritical, ""
Exit Sub
End If
lin = lin + 1
Loop
Sheets("Login").Cells(lin, gestor) = cdnome
Sheets("Login").Cells(lin, gestorsenha) = cdSenha
'...................................................................
'limpar
lsListaGestor.ListItems.Clear
lastRow = Plan3.Cells(Plan3.Cells.Rows.Count, "E").End(xlUp).Row
' Adiciona itens
For x = 3 To lastRow
Set li = lsListaGestor.ListItems.Add(Text:=Plan3.Cells(x, "E").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "F").Value
Next
ActiveWorkbook.Save
MsgBox "Gestor Cadastrado com Sucesso.", vbInformation, "Sistema Gestor - V 1.0"
Call LimparCampos
'Habilita
OptGestor.Enabled = True
OptGestor.Value = False
OptUsuario.Enabled = True
OptUsuario.Value = False
End If
End Sub
Sub LimparCampos()
Me.cdSenha.Text = ""
Me.cdnome.Text = ""
Me.cdNivel.Text = ""
End Sub
Private Sub btLimpar_Click()
Call LimparCampos
End Sub
Private Sub btsair_Click()
frmUsuario.Hide
frmMenu.Show
End Sub
Private Sub cdNome_Change()
cdnome.Value = UCase(cdnome.Value)
cdSenha = ""
cdNivel = ""
lin = 3
Do Until Sheets("Login").Cells(lin, nome) = ""
If cdnome = Sheets("Login").Cells(lin, nome) Then
If cdSenha = Sheets("Login").Cells(lin, senha) Then
End If
End If
lin = lin + 1
Loop
End Sub
Private Sub lsLista_Click()
cdnome = lsLista.SelectedItem
cdnome = lsListaGestor.SelectedItem
End Sub
Private Sub OptGestor_Click()
OptUsuario.Enabled = False
lsListaGestor.Visible = True
lsLista.Visible = False
Call HabilitaBotoes
Call HabilitaControleGestor
MsgBox "O Gestor tem Acesso Ilimitado ao Sistema!", vbInformation, ""
Call GestorlsLista
End Sub
Private Sub OptUsuario_Click()
OptGestor.Enabled = False
Call HabilitaBotoes
Call HabilitaControles
lsListaGestor.Visible = False
lsLista.Visible = True
Call UsuariolsLista
End Sub
Sub ComboBoxNivel()
cdNivel.AddItem "1"
cdNivel.AddItem "2"
cdNivel.AddItem "3"
cdNivel.AddItem "4"
End Sub
Private Sub UserForm_Initialize()
lsListaGestor.Visible = False
Call DesabilitaBotoes
Call DesabilitaControles
Call ComboBoxNivel
With frmUsuario
.Caption = "Cadastro de Usuários - [img][/img]"
End With
HideCloseButton Me
End Sub
Sub GestorlsLista()
' Adiciona as colunas
With lsListaGestor
.Gridlines = True
.View = lvwReport
.FullRowSelect = True
.ColumnHeaders.Add Text:="GESTOR", Width:=102
.ColumnHeaders.Add Text:="SENHA", Width:=88
End With
'...................................................................
'limpar
lsListaGestor.ListItems.Clear
lastRow = Plan3.Cells(Plan3.Cells.Rows.Count, "e").End(xlUp).Row
' Adiciona itens
For x = 3 To lastRow
Set li = lsListaGestor.ListItems.Add(Text:=Plan3.Cells(x, "e").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "f").Value
Next
End Sub
Sub UsuariolsLista()
' Adiciona as colunas
With lsLista
.Gridlines = True
.View = lvwReport
.FullRowSelect = True
.ColumnHeaders.Add Text:="USUÁRIO", Width:=102
.ColumnHeaders.Add Text:="SENHA", Width:=88
.ColumnHeaders.Add Text:="NIVEL", Width:=78
End With
'...................................................................
'limpar
lsLista.ListItems.Clear
lastRow = Plan3.Cells(Plan3.Cells.Rows.Count, "a").End(xlUp).Row
' Adiciona itens
For x = 3 To lastRow
Set li = lsLista.ListItems.Add(Text:=Plan3.Cells(x, "a").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "b").Value
li.ListSubItems.Add Text:=Plan3.Cells(x, "c").Value
Next
End Sub
Private Sub HabilitaControles()
Me.cdnome.Locked = False
Me.cdSenha.Locked = False
Me.cdNivel.Locked = False
Me.cdnome.BackColor = &HC0FFC0
Me.cdSenha.BackColor = &HC0FFC0
Me.cdNivel.BackColor = &HC0FFC0
End Sub
Private Sub DesabilitaControles()
Me.cdnome.Locked = True
Me.cdSenha.Locked = True
Me.cdNivel.Locked = True
Me.cdnome.BackColor = &HFFFFFF
Me.cdSenha.BackColor = &HFFFFFF
Me.cdNivel.BackColor = &HFFFFFF
End Sub
Private Sub HabilitaControleGestor()
Me.cdnome.Locked = False
Me.cdSenha.Locked = False
Me.cdnome.BackColor = &HC0FFC0
Me.cdSenha.BackColor = &HC0FFC0
End Sub
Private Sub HabilitaBotoes()
btInserir.Enabled = True
btAlterar.Enabled = True
btLimpar.Enabled = True
End Sub
Private Sub DesabilitaBotoes()
btInserir.Enabled = False
btAlterar.Enabled = False
btLimpar.Enabled = False
End Sub
Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante