Bom dia,
Adaptei o cadastro de acordo com minhas necessidades, e ele abre normalmente. No entanto, há 2 coisas que preciso que ele execute e já estudei os códigos e não consegui detectar onde está o problema:
1 - Ele não está salvando os cadastros feitos por mim
2 - Ao cadastrar um novo contato, ele mantém o nome do cliente mas ele carrega os dados cadastrais (endereço, cep, telefone, etc) do contato anterior. Ao sair e retornar ao programa, constatei que as informações não estão sendo salvas.
Segue abaixo o código. Alguém pode me ajudar?
Option Explicit
Const colCodigoDoCliente As Integer = 1
Const colCliente As Integer = 5
Const colEndereco As Integer = 6
Const colNumero As Integer = 7
Const colBairro As Integer = 8
Const colCidade As Integer = 9
Const colUF As Integer = 10
Const colCep As Integer = 11
Const colPais As Integer = 12
Const colDDD1 As Integer = 13
Const colTelefone1 As Integer = 14
Const colDDD2 As Integer = 15
Const colTelefone2 As Integer = 16
Const colSite As Integer = 17
Const colModalidadeDoCliente As Integer = 18
Const colCoordenador As Integer = 19
Const colRamalCoordenador As Integer = 20
Const colEmailCoordenador As Integer = 21
Const colCelularCoordenador As Integer = 22
Const colProjetista As Integer = 23
Const colRamalProjetista As Integer = 24
Const colEmailProjetista As Integer = 25
Const colCelularProjetista As Integer = 26
Const colVendedor As Integer = 27
Const colRamalVendedor As Integer = 28
Const colEmailVendedor As Integer = 29
Const colCelularVendedor As Integer = 30
Const colGestor As Integer = 31
Const colRamalGestor As Integer = 32
Const colEmailGestor As Integer = 33
Const colCelularGestor As Integer = 34
Const colContato1 As Integer = 35
Const colTelefoneContato1 As Integer = 36
Const colCelularContato1 As Integer = 37
Const colCargoContato1 As Integer = 38
Const colEmailContato1 As Integer = 39
Const colContato2 As Integer = 40
Const colTelefoneContato2 As Integer = 41
Const colCelularContato2 As Integer = 42
Const colCargoContato2 As Integer = 43
Const colEmailContato2 As Integer = 44
Const colContato3 As Integer = 45
Const colTelefoneContato3 As Integer = 46
Const colCelularContato3 As Integer = 47
Const colCargoContato3 As Integer = 48
Const colEmailContato3 As Integer = 49
Const colContato4 As Integer = 50
Const colTelefoneContato4 As Integer = 51
Const colCelularContato4 As Integer = 52
Const colCargoContato4 As Integer = 53
Const colEmailContato4 As Integer = 54
Const colContato5 As Integer = 55
Const colTelefoneContato5 As Integer = 56
Const colCelularContato5 As Integer = 57
Const colCargoContato5 As Integer = 58
Const colEmailContato5 As Integer = 59
Const colContato6 As Integer = 60
Const colTelefoneContato6 As Integer = 61
Const colCelularContato6 As Integer = 62
Const colCargoContato6 As Integer = 63
Const colEmailContato6 As Integer = 64
Const colContato7 As Integer = 65
Const colTelefoneContato7 As Integer = 66
Const colCelularContato7 As Integer = 67
Const colCargoContato7 As Integer = 68
Const colEmailContato7 As Integer = 69
Const ColContato8 As Integer = 70
Const ColTelefoneContato8 As Integer = 71
Const ColCelularContato8 As Integer = 72
Const ColCargoContato8 As Integer = 73
Const ColEmailContato8 As Integer = 74
Const ColContato9 As Integer = 75
Const ColTelefoneContato9 As Integer = 76
Const ColCelularContato9 As Integer = 77
Const ColCargoContato9 As Integer = 78
Const ColEmailContato9 As Integer = 79
Const ColContato10 As Integer = 80
Const ColTelefoneContato10 As Integer = 81
Const ColCelularContato10 As Integer = 82
Const ColCargoContato10 As Integer = 83
Const ColEmailContato10 As Integer = 84
Const ColContato11 As Integer = 85
Const ColTelefoneContato11 As Integer = 86
Const ColCelularContato11 As Integer = 87
Const ColCargoContato11 As Integer = 88
Const ColEmailContato11 As Integer = 89
Const ColContato12 As Integer = 90
Const ColTelefoneContato12 As Integer = 91
Const ColCelularContato12 As Integer = 92
Const ColCargoContato12 As Integer = 93
Const ColEmailContato12 As Integer = 94
Const ColContato13 As Integer = 95
Const ColTelefoneContato13 As Integer = 96
Const ColCelularContato13 As Integer = 97
Const ColCargoContato13 As Integer = 98
Const ColEmailContato13 As Integer = 99
Const ColContato14 As Integer = 100
Const ColTelefoneContato14 As Integer = 101
Const ColCelularContato14 As Integer = 102
Const ColCargoContato14 As Integer = 103
Const ColEmailContato14 As Integer = 104
Const ColContato15 As Integer = 105
Const ColTelefoneContato15 As Integer = 106
Const ColCelularContato15 As Integer = 107
Const ColCargoContato15 As Integer = 108
Const ColEmailContato15 As Integer = 109
Const ColContato16 As Integer = 110
Const ColTelefoneContato16 As Integer = 111
Const ColCelularContato16 As Integer = 112
Const ColCargoContato16 As Integer = 113
Const ColEmailContato16 As Integer = 114
Const ColContato17 As Integer = 115
Const ColTelefoneContato17 As Integer = 116
Const ColCelularContato17 As Integer = 117
Const ColCargoContato17 As Integer = 118
Const ColEmailContato17 As Integer = 119
Const ColContato18 As Integer = 120
Const ColTelefoneContato18 As Integer = 121
Const ColCelularContato18 As Integer = 122
Const ColCargoContato18 As Integer = 123
Const ColEmailContato18 As Integer = 124
Const ColContato19 As Integer = 125
Const ColTelefoneContato19 As Integer = 126
Const ColCelularContato19 As Integer = 127
Const ColCargoContato19 As Integer = 128
Const ColEmailContato19 As Integer = 129
Const ColContato20 As Integer = 130
Const ColTelefoneContato20 As Integer = 131
Const ColCelularContato20 As Integer = 132
Const ColCargoContato20 As Integer = 133
Const ColEmailContato20 As Integer = 134
Const ColContato21 As Integer = 135
Const ColTelefoneContato21 As Integer = 136
Const ColCelularContato21 As Integer = 137
Const ColCargoContato21 As Integer = 138
Const ColEmailContato21 As Integer = 139
Const ColContato22 As Integer = 140
Const ColTelefoneContato22 As Integer = 141
Const ColCelularContato22 As Integer = 142
Const ColCargoContato22 As Integer = 143
Const ColEmailContato22 As Integer = 144
Const ColContato23 As Integer = 145
Const ColTelefoneContato23 As Integer = 146
Const ColCelularContato23 As Integer = 147
Const ColCargoContato23 As Integer = 148
Const ColEmailContato23 As Integer = 149
Const ColContato24 As Integer = 150
Const ColTelefoneContato24 As Integer = 151
Const ColCelularContato24 As Integer = 152
Const ColCargoContato24 As Integer = 153
Const ColEmailContato24 As Integer = 154
Const ColContato25 As Integer = 155
Const ColTelefoneContato25 As Integer = 156
Const ColCelularContato25 As Integer = 157
Const ColCargoContato25 As Integer = 158
Const ColEmailContato25 As Integer = 159
Const colPendRelatorio As Integer = 225
Const colPendAprovacao As Integer = 226
Const colAnotacoes1 As Integer = 227
Const colAnotacoes2 As Integer = 228
Const colAnotacoes3 As Integer = 229
Const colAnotacoes4 As Integer = 230
Const colAnotacoes5 As Integer = 231
Const colFluxo As Integer = 53
Const indiceMinimo As Byte = 2
Const corDisabledTextBox As Long = -2147483633
Const corEnabledTextBox As Long = -2147483643
Const nomePlanilhaCadastro As String = "Clientes"
Private wsCadastro As Worksheet
Private wbCadastro As Workbook
Private indiceRegistro As Long
Private Sub btnCancelar_Click()
btnOK.Enabled = False
btnCancelar.Enabled = False
Call DesabilitaControles
Call CarregaDadosInicial
Call HabilitaBotoesAlteracao
End Sub
Private Sub btnobras_Click()
frmObras.Show
End Sub
Private Sub btnOK_Click()
Dim proximoId As Long
'Altera
If optAlterar.Value Then
Call SalvaRegistro(CLng(txtCodigoDoCliente.Text), indiceRegistro)
lblMensagem.Caption = "Registro salvo com sucesso"
End If
'Novo
If optNovo.Value Then
proximoId = PegaProximoId
'pega a próxima linha
Dim proximoIndice As Long
'atualiza o arquivo para pegar o próximo registro atualizado
Call AtualizarArquivo(False)
proximoIndice = wsCadastro.UsedRange.Rows.Count + 1
Call SalvaRegistro(proximoId, proximoIndice)
txtCodigoDoCliente = proximoId
lblMensagem.Caption = "Registro salvo com sucesso"
End If
'Excluir
If optExcluir.Value Then
Dim result As VbMsgBoxResult
result = MsgBox("Deseja excluir o registro nº " & txtCodigoDoCliente.Text & " ?", vbYesNo, "Confirmação")
If result = vbYes Then
'abre o arquivo para escrita
Call AtualizarArquivo(False)
wsCadastro.Range(wsCadastro.Cells(indiceRegistro, colCodigoDoCliente), wsCadastro.Cells(indiceRegistro, colCodigoDoCliente)).EntireRow.Delete
'salva
wbCadastro.Save
'abre somente leitura
Call AtualizarArquivo(True)
Call CarregaDadosInicial
lblMensagem.Caption = "Registro excluído com sucesso"
End If
End If
Call HabilitaBotoesAlteracao
Call DesabilitaControles
End Sub
Private Sub btnPesquisar_Click()
frmPesquisa.Show
End Sub
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
btnobras.Visible = True
CheckBox1.Caption = "JÁ TEVE OBRA FABRICADA PELA AÇOTEC"
CheckBox1.Font.Bold = True
btnobras.SetFocus
Else
btnobras.Visible = False
CheckBox1.Caption = "NÃO POSSUI OBRA FABRICADA PELA AÇOTEC"
CheckBox1.Font.Bold = False
End If
End Sub
Private Sub Frame20_Click()
End Sub
Private Sub frmRegistro_Click()
End Sub
Private Sub Label177_Click()
End Sub
Private Sub Label202_Click()
End Sub
Private Sub Label205_Click()
End Sub
Private Sub Label208_Click()
End Sub
Private Sub Label228_Click()
End Sub
Private Sub Label244_Click()
End Sub
Private Sub Label257_Click()
End Sub
Private Sub Label260_Click()
End Sub
Private Sub Label270_Click()
End Sub
Private Sub Label296_Click()
End Sub
Private Sub frmCadastro_Click()
End Sub
Private Sub Label309_Click()
End Sub
Private Sub Label348_Click()
End Sub
Private Sub Label358_Click()
End Sub
Private Sub Label359_Click()
End Sub
Private Sub Label49_Click()
End Sub
Private Sub Label57_Click()
End Sub
Private Sub lblAnotacoes8_Click()
End Sub
Private Sub optAlterar_Click()
If txtCodigoDoCliente.Text <> vbNullString And txtCodigoDoCliente.Text <> "" Then
Call HabilitaControles
Call DesabilitaBotoesAlteracao
'dá o foco ao primeiro controle de dados
' txtCliente.SetFocus
Else
lblMensagem.Caption = "Não há registro a ser alterado"
End If
End Sub
Private Sub optExcluir_Click()
If txtCodigoDoCliente.Text <> vbNullString And txtCodigoDoCliente.Text <> "" Then
Call DesabilitaBotoesAlteracao
lblMensagem.Caption = "Modo de exclusão. Confira o dados do registro antes de excluí-lo"
Else
lblMensagem.Caption = "Não há registro a ser excluído"
End If
End Sub
Private Sub optNovo_Click()
Call LimpaControles
Call HabilitaControles
Call DesabilitaBotoesAlteracao
'dá o foco ao primeiro controle de dados
' txtCliente.SetFocus
End Sub
Private Sub TextBox202_Change()
End Sub
Private Sub TextBox39_Change()
End Sub
Private Sub txtCliente_Change()
End Sub
Private Sub txtPais_Change()
End Sub
Private Sub UserForm_Initialize()
Call DefinePlanilhaDados
Call HabilitaBotoesAlteracao
Call CarregaDadosInicial
Call DesabilitaControles
lblusuario.Caption = VBA.Environ("Username")
lblData.Caption = Date
End Sub
Private Sub btnAnterior_Click()
If indiceRegistro > indiceMinimo Then
indiceRegistro = indiceRegistro - 1
End If
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub btnPrimeiro_Click()
indiceRegistro = indiceMinimo
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub btnProximo_Click()
If indiceRegistro < wsCadastro.UsedRange.Rows.Count Then
indiceRegistro = indiceRegistro + 1
End If
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub btnUltimo_Click()
indiceRegistro = wsCadastro.UsedRange.Rows.Count
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub CarregaDadosInicial()
indiceRegistro = 2
Call CarregaRegistro
End Sub
Private Sub CarregaRegistro()
'carrega os dados do primeiro registro
With wsCadastro
If Not IsEmpty(.Cells(indiceRegistro, colCodigoDoCliente)) Then
Me.txtCodigoDoCliente.Text = .Cells(indiceRegistro, colCodigoDoCliente).Value
Me.txtCliente.Text = .Cells(indiceRegistro, colCliente).Value
Me.ICliente.Text = .Cells(indiceRegistro, colCliente).Value
Me.IPEDIDO.Text = .Cells(indiceRegistro, colContato1).Value
End If
End With
Call AtualizaRegistroCorrente
End Sub
Public Sub CarregaRegistroPorIndice(ByVal indice As Long)
'carrega os dados do registro baseado no índice
indiceRegistro = indice
Call CarregaRegistro
End Sub
Private Sub AtualizarArquivo(ByVal ReadOnly As Boolean)
Dim caminhoCompleto As String
'fecha o arquivo de dados e tenta abrí-lo
'guarda o caminho
caminhoCompleto = wbCadastro.FullName
wbCadastro.Saved = True
wbCadastro.Close SaveChanges:=False
'abre o arquivo em modo escrita
Set wbCadastro = Workbooks.Open(Filename:=caminhoCompleto, ReadOnly:=ReadOnly)
'oculta a janela
wbCadastro.Windows(1).Visible = False
'reatribui a planilha de cadastro
Set wsCadastro = wbCadastro.Worksheets(nomePlanilhaCadastro)
End Sub
Private Sub SalvaRegistro(ByVal id As Long, ByVal indice As Long)
'tenta abrir o arquivo em modo escrita
Call AtualizarArquivo(False)
With wsCadastro
.Cells(indice, colCodigoDoCliente).Value = id
.Cells(indice, colCliente).Value = Me.txtCliente.Text
.Cells(indice, colEndereco).Value = Me.txtEndereco.Text
.Cells(indice, colBairro).Value = Me.txtBairro.Text
.Cells(indice, colCidade).Value = Me.txtCidade.Text
.Cells(indice, colUF).Value = Me.txtUF.Text
.Cells(indice, colCep).Value = Me.txtCep.Text
.Cells(indice, colPais).Value = Me.txtPais.Text
.Cells(indice, colDDD1).Value = Me.txtDDD1.Text
.Cells(indice, colTelefone1).Value = Me.txtTelefone1.Text
.Cells(indice, colDDD2).Value = Me.txtDDD2.Text
.Cells(indice, colTelefone2).Value = Me.txtTelefone2.Text
.Cells(indice, colSite).Value = Me.txtSite.Text
.Cells(indice, colModalidadeDoCliente).Value = Me.txtModalidadeDoCliente.Text
.Cells(indice, colCoordenador).Value = Me.txtCoordenador.Text
.Cells(indice, colRamalCoordenador).Value = Me.txtRamalCoordenador.Text
.Cells(indice, colEmailCoordenador).Value = Me.txtEmailCoordenador.Text
.Cells(indice, colCelularCoordenador).Value = Me.txtCelularCoordenador.Text
.Cells(indice, colProjetista).Value = Me.txtProjetista.Text
.Cells(indice, colRamalProjetista).Value = Me.txtRamalProjetista.Text
.Cells(indice, colEmailProjetista).Value = Me.txtEmailProjetista.Text
.Cells(indice, colCelularProjetista).Value = Me.txtCelularProjetista.Text
.Cells(indice, colVendedor).Value = Me.txtVendedor.Text
.Cells(indice, colRamalVendedor).Value = Me.txtRamalVendedor.Text
.Cells(indice, colEmailVendedor).Value = Me.txtEmailVendedor.Text
.Cells(indice, colCelularVendedor).Value = Me.TxtCelularVendedor.Text
.Cells(indice, colGestor).Value = Me.txtGestor.Text
.Cells(indice, colRamalGestor).Value = Me.txtRamalGestor.Text
.Cells(indice, colEmailGestor).Value = Me.txtEmailGestor.Text
.Cells(indice, colCelularGestor).Value = Me.txtCelularGestor.Text
.Cells(indice, colContato1).Value = Me.txtContato1.Text
.Cells(indice, colTelefoneContato1).Value = Me.txtTelefoneContato1.Text
.Cells(indice, colCelularContato1).Value = Me.txtCelularContato1.Text
.Cells(indice, colCargoContato1).Value = Me.txtCargoContato1.Text
.Cells(indice, colEmailContato1).Value = Me.txtEmailContato1.Text
.Cells(indice, colContato2).Value = Me.txtContato2.Text
.Cells(indice, colTelefoneContato2).Value = Me.txtTelefoneContato2.Text
.Cells(indice, colCelularContato2).Value = Me.txtCelularContato2.Text
.Cells(indice, colCargoContato2).Value = Me.txtCargoContato2.Text
.Cells(indice, colEmailContato2).Value = Me.txtEmailContato2.Text
.Cells(indice, colContato3).Value = Me.txtContato3.Text
.Cells(indice, colTelefoneContato3).Value = Me.txtTelefoneContato3.Text
.Cells(indice, colCelularContato3).Value = Me.txtCelularContato3.Text
.Cells(indice, colCargoContato3).Value = Me.txtCargoContato3.Text
.Cells(indice, colEmailContato3).Value = Me.txtEmailContato3.Text
.Cells(indice, colContato4).Value = Me.txtContato4.Text
.Cells(indice, colTelefoneContato4).Value = Me.txtTelefoneContato4.Text
.Cells(indice, colCelularContato4).Value = Me.txtCelularContato4.Text
.Cells(indice, colCargoContato4).Value = Me.txtCargoContato4.Text
.Cells(indice, colEmailContato4).Value = Me.txtEmailContato4.Text
.Cells(indice, colContato5).Value = Me.txtContato5.Text
.Cells(indice, colTelefoneContato5).Value = Me.txtTelefoneContato5.Text
.Cells(indice, colCelularContato5).Value = Me.txtCelularContato5.Text
.Cells(indice, colCargoContato5).Value = Me.txtCargoContato5.Text
.Cells(indice, colEmailContato5).Value = Me.txtEmailContato5.Text
.Cells(indice, colContato6).Value = Me.txtContato6.Text
.Cells(indice, colTelefoneContato6).Value = Me.txtTelefoneContato6.Text
.Cells(indice, colCelularContato6).Value = Me.txtCelularContato6.Text
.Cells(indice, colCargoContato6).Value = Me.txtCargoContato6.Text
.Cells(indice, colEmailContato6).Value = Me.txtEmailContato6.Text
.Cells(indice, colContato7).Value = Me.txtContato7.Text
.Cells(indice, colTelefoneContato7).Value = Me.txtTelefoneContato7.Text
.Cells(indice, colCelularContato7).Value = Me.txtCelularContato7.Text
.Cells(indice, colCargoContato7).Value = Me.txtCargoContato7.Text
.Cells(indice, colEmailContato7).Value = Me.txtEmailContato7.Text
.Cells(indice, ColContato8).Value = Me.txtContato8.Text
.Cells(indice, ColTelefoneContato8).Value = Me.txtTelefoneContato8.Text
.Cells(indice, ColCelularContato8).Value = Me.txtCelularContato8.Text
.Cells(indice, ColCargoContato8).Value = Me.txtCargoContato8.Text
.Cells(indice, ColEmailContato8).Value = Me.txtEmailContato8.Text
.Cells(indice, ColContato9).Value = Me.txtContato9.Text
.Cells(indice, ColTelefoneContato9).Value = Me.txtTelefoneContato9.Text
.Cells(indice, ColCelularContato9).Value = Me.txtCelularContato9.Text
.Cells(indice, ColCargoContato9).Value = Me.txtCargoContato9.Text
.Cells(indice, ColEmailContato9).Value = Me.txtEmailContato9.Text
.Cells(indice, ColContato10).Value = Me.txtContato10.Text
.Cells(indice, ColTelefoneContato10).Value = Me.txtTelefoneContato10.Text
.Cells(indice, ColCelularContato10).Value = Me.txtCelularContato10.Text
.Cells(indice, ColCargoContato10).Value = Me.txtCargoContato10.Text
.Cells(indice, ColEmailContato10).Value = Me.txtEmailContato10.Text
.Cells(indice, ColContato11).Value = Me.txtContato11.Text
.Cells(indice, ColTelefoneContato11).Value = Me.txtTelefoneContato11.Text
.Cells(indice, ColCelularContato11).Value = Me.txtCelularContato11.Text
.Cells(indice, ColCargoContato11).Value = Me.txtCargoContato11.Text
.Cells(indice, ColEmailContato11).Value = Me.txtEmailContato11.Text
.Cells(indice, ColContato12).Value = Me.txtContato12.Text
.Cells(indice, ColTelefoneContato12).Value = Me.txtTelefoneContato12.Text
.Cells(indice, ColCelularContato12).Value = Me.txtCelularContato12.Text
.Cells(indice, ColCargoContato12).Value = Me.txtCargoContato12.Text
.Cells(indice, ColEmailContato12).Value = Me.txtEmailContato12.Text
.Cells(indice, ColContato13).Value = Me.txtContato13.Text
.Cells(indice, ColTelefoneContato13).Value = Me.txtTelefoneContato13.Text
.Cells(indice, ColCelularContato13).Value = Me.txtCelularContato13.Text
.Cells(indice, ColCargoContato13).Value = Me.txtCargoContato13.Text
.Cells(indice, ColEmailContato13).Value = Me.txtEmailContato13.Text
.Cells(indice, ColContato14).Value = Me.txtContato14.Text
.Cells(indice, ColTelefoneContato14).Value = Me.txtTelefoneContato14.Text
.Cells(indice, ColCelularContato14).Value = Me.txtCelularContato14.Text
.Cells(indice, ColCargoContato14).Value = Me.txtCargoContato14.Text
.Cells(indice, ColEmailContato14).Value = Me.txtEmailContato14.Text
.Cells(indice, ColContato15).Value = Me.txtContato15.Text
.Cells(indice, ColTelefoneContato15).Value = Me.txtTelefoneContato15.Text
.Cells(indice, ColCelularContato15).Value = Me.txtCelularContato15.Text
.Cells(indice, ColCargoContato15).Value = Me.txtCargoContato15.Text
.Cells(indice, ColEmailContato15).Value = Me.txtEmailContato15.Text
.Cells(indice, ColContato16).Value = Me.txtContato16.Text
.Cells(indice, ColTelefoneContato16).Value = Me.txtTelefoneContato16.Text
.Cells(indice, ColCelularContato16).Value = Me.txtCelularContato16.Text
.Cells(indice, ColCargoContato16).Value = Me.txtCargoContato16.Text
.Cells(indice, ColEmailContato16).Value = Me.txtEmailContato16.Text
.Cells(indice, ColContato10).Value = Me.txtContato17.Text
.Cells(indice, ColTelefoneContato17).Value = Me.txtTelefoneContato17.Text
.Cells(indice, ColCelularContato17).Value = Me.txtCelularContato17.Text
.Cells(indice, ColCargoContato17).Value = Me.txtCargoContato17.Text
.Cells(indice, ColEmailContato17).Value = Me.txtEmailContato17.Text
.Cells(indice, ColContato18).Value = Me.txtContato18.Text
.Cells(indice, ColTelefoneContato18).Value = Me.txtTelefoneContato18.Text
.Cells(indice, ColCelularContato18).Value = Me.txtCelularContato18.Text
.Cells(indice, ColCargoContato18).Value = Me.txtCargoContato18.Text
.Cells(indice, ColEmailContato18).Value = Me.txtEmailContato18.Text
.Cells(indice, ColContato19).Value = Me.txtContato19.Text
.Cells(indice, ColTelefoneContato19).Value = Me.txtTelefoneContato19.Text
.Cells(indice, ColCelularContato19).Value = Me.txtCelularContato19.Text
.Cells(indice, ColCargoContato19).Value = Me.txtCargoContato19.Text
.Cells(indice, ColEmailContato19).Value = Me.txtEmailContato19.Text
.Cells(indice, ColContato20).Value = Me.txtContato20.Text
.Cells(indice, ColTelefoneContato20).Value = Me.txtTelefoneContato20.Text
.Cells(indice, ColCelularContato20).Value = Me.txtCelularContato20.Text
.Cells(indice, ColCargoContato20).Value = Me.txtCargoContato20.Text
.Cells(indice, ColEmailContato20).Value = Me.txtEmailContato20.Text
.Cells(indice, ColContato21).Value = Me.txtContato21.Text
.Cells(indice, ColTelefoneContato21).Value = Me.txtTelefoneContato21.Text
.Cells(indice, ColCelularContato21).Value = Me.txtCelularContato21.Text
.Cells(indice, ColCargoContato21).Value = Me.txtCargoContato21.Text
.Cells(indice, ColEmailContato21).Value = Me.txtEmailContato21.Text
.Cells(indice, ColContato22).Value = Me.txtContato22.Text
.Cells(indice, ColTelefoneContato22).Value = Me.txtTelefoneContato22.Text
.Cells(indice, ColCelularContato22).Value = Me.txtCelularContato22.Text
.Cells(indice, ColCargoContato22).Value = Me.txtCargoContato22.Text
.Cells(indice, ColEmailContato22).Value = Me.txtEmailContato22.Text
.Cells(indice, ColContato23).Value = Me.txtContato23.Text
.Cells(indice, ColTelefoneContato23).Value = Me.txtTelefoneContato23.Text
.Cells(indice, ColCelularContato23).Value = Me.txtCelularContato23.Text
.Cells(indice, ColCargoContato23).Value = Me.txtCargoContato23.Text
.Cells(indice, ColEmailContato23).Value = Me.txtEmailContato23.Text
.Cells(indice, ColContato24).Value = Me.txtContato24.Text
.Cells(indice, ColTelefoneContato24).Value = Me.txtTelefoneContato24.Text
.Cells(indice, ColCelularContato24).Value = Me.txtCelularContato24.Text
.Cells(indice, ColCargoContato24).Value = Me.txtCargoContato24.Text
.Cells(indice, ColEmailContato24).Value = Me.txtEmailContato24.Text
.Cells(indice, ColContato25).Value = Me.txtContato25.Text
.Cells(indice, ColTelefoneContato25).Value = Me.txtTelefoneContato25.Text
.Cells(indice, ColCelularContato25).Value = Me.txtCelularContato25.Text
.Cells(indice, ColCargoContato25).Value = Me.txtCargoContato25.Text
.Cells(indice, ColEmailContato25).Value = Me.txtEmailContato25.Text
.Cells(indice, colAnotacoes1).Value = Me.txtAnotacoes1.Text
.Cells(indice, colAnotacoes2).Value = Me.txtAnotacoes2.Text
.Cells(indice, colAnotacoes3).Value = Me.txtAnotacoes3.Text
.Cells(indice, colAnotacoes4).Value = Me.txtAnotacoes4.Text
.Cells(indice, colAnotacoes5).Value = Me.txtAnotacoes5.Text
End With
'salva o arquivo
Call wbCadastro.Save
'abre o arquivo novamente em modo leitura
Call AtualizarArquivo(True)
Call AtualizaRegistroCorrente
End Sub
Private Function PegaProximoId() As Long
Dim rangeIds As Range
'pega o range que se refere a toda a coluna do código (id)
Set rangeIds = wsCadastro.Range(wsCadastro.Cells(indiceMinimo, colCodigoDoCliente), wsCadastro.Cells(wsCadastro.UsedRange.Rows.Count, colCodigoDoCliente))
PegaProximoId = WorksheetFunction.Max(rangeIds) + 1
End Function
Private Sub AtualizaRegistroCorrente()
lblNavigator.Caption = indiceRegistro - 1 & " de " & wsCadastro.UsedRange.Rows.Count - 1
lblMensagem.Caption = ""
End Sub
Private Sub LimpaControles()
Me.txtCodigoDoCliente.Text = ""
Me.txtCliente.Text = ""
Me.txtEndereco.Text = ""
Me.txtBairro.Text = ""
Me.txtCidade.Text = ""
Me.txtUF.Text = ""
Me.txtCep.Text = ""
Me.txtPais.Text = ""
Me.txtDDD1.Text = ""
Me.txtTelefone1.Text = ""
Me.txtDDD2.Text = ""
Me.txtTelefone2.Text = ""
Me.txtSite.Text = ""
Me.txtCoordenador.Text = ""
Me.txtRamalCoordenador.Text = ""
Me.txtEmailCoordenador.Text = ""
Me.txtCelularCoordenador.Text = ""
Me.txtProjetista.Text = ""
Me.txtRamalProjetista.Text = ""
Me.txtEmailProjetista.Text = ""
Me.txtCelularProjetista.Text = ""
Me.txtVendedor.Text = ""
Me.txtRamalVendedor.Text = ""
Me.txtEmailVendedor.Text = ""
Me.TxtCelularVendedor.Text = ""
Me.txtGestor.Text = ""
Me.txtRamalGestor.Text = ""
Me.txtEmailGestor.Text = ""
Me.txtCelularGestor.Text = ""
Me.txtContato1.Text = ""
Me.txtTelefoneContato1.Text = ""
Me.txtCelularContato1.Text = ""
Me.txtCargoContato1.Text = ""
Me.txtEmailContato1.Text = ""
Me.txtContato2.Text = ""
Me.txtTelefoneContato2.Text = ""
Me.txtCelularContato2.Text = ""
Me.txtCargoContato2.Text = ""
Me.txtEmailContato2.Text = ""
Me.txtContato3.Text = ""
Me.txtTelefoneContato3.Text = ""
Me.txtCelularContato3.Text = ""
Me.txtCargoContato3.Text = ""
Me.txtEmailContato3.Text = ""
Me.txtContato4.Text = ""
Me.txtTelefoneContato4.Text = ""
Me.txtCelularContato4.Text = ""
Me.txtCargoContato4.Text = ""
Me.txtEmailContato4.Text = ""
Me.txtContato5.Text = ""
Me.txtTelefoneContato5.Text = ""
Me.txtCelularContato5.Text = ""
Me.txtCargoContato5.Text = ""
Me.txtEmailContato5.Text = ""
Me.txtContato6.Text = ""
Me.txtTelefoneContato6.Text = ""
Me.txtCelularContato6.Text = ""
Me.txtCargoContato6.Text = ""
Me.txtEmailContato6.Text = ""
Me.txtContato7.Text = ""
Me.txtTelefoneContato7.Text = ""
Me.txtCelularContato7.Text = ""
Me.txtCargoContato7.Text = ""
Me.txtEmailContato7.Text = ""
Me.txtContato8.Text = ""
Me.txtTelefoneContato8.Text = ""
Me.txtCelularContato8.Text = ""
Me.txtCargoContato8.Text = ""
Me.txtEmailContato8.Text = ""
Me.txtContato9.Text = ""
Me.txtTelefoneContato9.Text = ""
Me.txtCelularContato9.Text = ""
Me.txtCargoContato9.Text = ""
Me.txtEmailContato9.Text = ""
Me.txtContato10.Text = ""
Me.txtTelefoneContato10.Text = ""
Me.txtCelularContato10.Text = ""
Me.txtCargoContato10.Text = ""
Me.txtEmailContato10.Text = ""
Me.txtContato11.Text = ""
Me.txtTelefoneContato11.Text = ""
Me.txtCelularContato11.Text = ""
Me.txtCargoContato11.Text = ""
Me.txtEmailContato11.Text = ""
Me.txtContato12.Text = ""
Me.txtTelefoneContato12.Text = ""
Me.txtCelularContato12.Text = ""
Me.txtCargoContato12.Text = ""
Me.txtEmailContato12.Text = ""
Me.txtContato13.Text = ""
Me.txtTelefoneContato13.Text = ""
Me.txtCelularContato13.Text = ""
Me.txtCargoContato13.Text = ""
Me.txtEmailContato13.Text = ""
Me.txtContato14.Text = ""
Me.txtTelefoneContato14.Text = ""
Me.txtCelularContato14.Text = ""
Me.txtCargoContato14.Text = ""
Me.txtEmailContato14.Text = ""
Me.txtContato15.Text = ""
Me.txtTelefoneContato15.Text = ""
Me.txtCelularContato15.Text = ""
Me.txtCargoContato15.Text = ""
Me.txtEmailContato15.Text = ""
Me.txtContato16.Text = ""
Me.txtTelefoneContato16.Text = ""
Me.txtCelularContato16.Text = ""
Me.txtCargoContato16.Text = ""
Me.txtEmailContato16.Text = ""
Me.txtContato17.Text = ""
Me.txtTelefoneContato17.Text = ""
Me.txtCelularContato17.Text = ""
Me.txtCargoContato17.Text = ""
Me.txtEmailContato17.Text = ""
Me.txtContato18.Text = ""
Me.txtTelefoneContato18.Text = ""
Me.txtCelularContato18.Text = ""
Me.txtCargoContato18.Text = ""
Me.txtEmailContato18.Text = ""
Me.txtContato19.Text = ""
Me.txtTelefoneContato19.Text = ""
Me.txtCelularContato19.Text = ""
Me.txtCargoContato19.Text = ""
Me.txtEmailContato19.Text = ""
Me.txtContato20.Text = ""
Me.txtTelefoneContato20.Text = ""
Me.txtCelularContato20.Text = ""
Me.txtCargoContato20.Text = ""
Me.txtEmailContato20.Text = ""
Me.txtContato21.Text = ""
Me.txtTelefoneContato21.Text = ""
Me.txtCelularContato21.Text = ""
Me.txtCargoContato21.Text = ""
Me.txtEmailContato21.Text = ""
Me.txtContato22.Text = ""
Me.txtTelefoneContato22.Text = ""
Me.txtCelularContato22.Text = ""
Me.txtCargoContato22.Text = ""
Me.txtEmailContato22.Text = ""
Me.txtContato23.Text = ""
Me.txtTelefoneContato23.Text = ""
Me.txtCelularContato23.Text = ""
Me.txtCargoContato23.Text = ""
Me.txtEmailContato23.Text = ""
Me.txtContato24.Text = ""
Me.txtTelefoneContato24.Text = ""
Me.txtCelularContato24.Text = ""
Me.txtCargoContato24.Text = ""
Me.txtEmailContato24.Text = ""
Me.txtContato25.Text = ""
Me.txtTelefoneContato25.Text = ""
Me.txtCelularContato25.Text = ""
Me.txtCargoContato25.Text = ""
Me.txtEmailContato25.Text = ""
Me.txtAnotacoes1.Text = ""
Me.txtAnotacoes2.Text = ""
Me.txtAnotacoes3.Text = ""
Me.txtAnotacoes4.Text = ""
Me.txtAnotacoes5.Text = ""
End Sub
Private Sub HabilitaControles()
'Me.txtCodigoDoCliente.Locked = False
Me.txtCliente.Locked = False
Me.txtEndereco.Locked = False
Me.txtBairro.Locked = False
Me.txtCidade.Locked = False
Me.txtUF.Locked = False
Me.txtCep.Locked = False
Me.txtPais.Locked = False
Me.txtDDD1.Locked = False
Me.txtTelefone1.Locked = False
Me.txtDDD2.Locked = False
Me.txtTelefone2.Locked = False
Me.txtSite.Locked = False
Me.txtModalidadeDoCliente.Locked = False
Me.txtCoordenador.Locked = False
Me.txtRamalCoordenador.Locked = False
Me.txtEmailCoordenador.Locked = False
Me.txtCelularCoordenador.Locked = False
Me.txtProjetista.Locked = False
Me.txtRamalProjetista.Locked = False
Me.txtEmailProjetista.Locked = False
Me.txtCelularProjetista.Locked = False
Me.txtVendedor.Locked = False
Me.txtRamalVendedor.Locked = False
Me.txtEmailVendedor.Locked = False
Me.TxtCelularVendedor.Locked = False
Me.txtGestor.Locked = False
Me.txtRamalGestor.Locked = False
Me.txtEmailGestor.Locked = False
Me.txtCelularGestor.Locked = False
Me.txtContato1.Locked = False
Me.txtTelefoneContato1.Locked = False
Me.txtCelularContato1.Locked = False
Me.txtCargoContato1.Locked = False
Me.txtEmailContato1.Locked = False
Me.txtContato2.Locked = False
Me.txtTelefoneContato2.Locked = False
Me.txtCelularContato2.Locked = False
Me.txtCargoContato2.Locked = False
Me.txtEmailContato2.Locked = False
Me.txtContato3.Locked = False
Me.txtTelefoneContato3.Locked = False
Me.txtCelularContato3.Locked = False
Me.txtCargoContato3.Locked = False
Me.txtEmailContato3.Locked = False
Me.txtContato4.Locked = False
Me.txtTelefoneContato4.Locked = False
Me.txtCelularContato4.Locked = False
Me.txtCargoContato4.Locked = False
Me.txtEmailContato4.Locked = False
Me.txtContato5.Locked = False
Me.txtTelefoneContato5.Locked = False
Me.txtCelularContato5.Locked = False
Me.txtCargoContato5.Locked = False
Me.txtEmailContato5.Locked = False
Me.txtContato6.Locked = False
Me.txtTelefoneContato6.Locked = False
Me.txtCelularContato6.Locked = False
Me.txtCargoContato6.Locked = False
Me.txtEmailContato6.Locked = False
Me.txtContato7.Locked = False
Me.txtTelefoneContato7.Locked = False
Me.txtCelularContato7.Locked = False
Me.txtCargoContato7.Locked = False
Me.txtEmailContato7.Locked = False
Me.txtContato8.Locked = False
Me.txtTelefoneContato8.Locked = False
Me.txtCelularContato8.Locked = False
Me.txtCargoContato8.Locked = False
Me.txtEmailContato8.Locked = False
Me.txtContato9.Locked = False
Me.txtTelefoneContato9.Locked = False
Me.txtCelularContato9.Locked = False
Me.txtCargoContato9.Locked = False
Me.txtEmailContato9.Locked = False
Me.txtContato10.Locked = False
Me.txtTelefoneContato10.Locked = False
Me.txtCelularContato10.Locked = False
Me.txtCargoContato10.Locked = False
Me.txtEmailContato10.Locked = False
Me.txtContato11.Locked = False
Me.txtTelefoneContato11.Locked = False
Me.txtCelularContato11.Locked = False
Me.txtCargoContato11.Locked = False
Me.txtEmailContato11.Locked = False
Me.txtContato12.Locked = False
Me.txtTelefoneContato12.Locked = False
Me.txtCelularContato12.Locked = False
Me.txtCargoContato12.Locked = False
Me.txtEmailContato12.Locked = False
Me.txtContato13.Locked = False
Me.txtTelefoneContato13.Locked = False
Me.txtCelularContato13.Locked = False
Me.txtCargoContato13.Locked = False
Me.txtEmailContato13.Locked = False
Me.txtContato14.Locked = False
Me.txtTelefoneContato14.Locked = False
Me.txtCelularContato14.Locked = False
Me.txtCargoContato14.Locked = False
Me.txtEmailContato14.Locked = False
Me.txtContato15.Locked = False
Me.txtTelefoneContato15.Locked = False
Me.txtCelularContato15.Locked = False
Me.txtCargoContato15.Locked = False
Me.txtEmailContato15.Locked = False
Me.txtContato16.Locked = False
Me.txtTelefoneContato16.Locked = False
Me.txtCelularContato16.Locked = False
Me.txtCargoContato16.Locked = False
Me.txtEmailContato16.Locked = False
Me.txtContato17.Locked = False
Me.txtTelefoneContato17.Locked = False
Me.txtCelularContato17.Locked = False
Me.txtCargoContato17.Locked = False
Me.txtEmailContato17.Locked = False
Me.txtContato18.Locked = False
Me.txtTelefoneContato18.Locked = False
Me.txtCelularContato18.Locked = False
Me.txtCargoContato18.Locked = False
Me.txtEmailContato18.Locked = False
Me.txtContato19.Locked = False
Me.txtTelefoneContato19.Locked = False
Me.txtCelularContato19.Locked = False
Me.txtCargoContato19.Locked = False
Me.txtEmailContato19.Locked = False
Me.txtContato20.Locked = False
Me.txtTelefoneContato20.Locked = False
Me.txtCelularContato20.Locked = False
Me.txtCargoContato20.Locked = False
Me.txtEmailContato20.Locked = False
Me.txtContato21.Locked = False
Me.txtTelefoneContato21.Locked = False
Me.txtCelularContato21.Locked = False
Me.txtCargoContato21.Locked = False
Me.txtEmailContato21.Locked = False
Me.txtContato22.Locked = False
Me.txtTelefoneContato22.Locked = False
Me.txtCelularContato22.Locked = False
Me.txtCargoContato22.Locked = False
Me.txtEmailContato22.Locked = False
Me.txtContato23.Locked = False
Me.txtTelefoneContato23.Locked = False
Me.txtCelularContato23.Locked = False
Me.txtCargoContato23.Locked = False
Me.txtEmailContato23.Locked = False
Me.txtContato24.Locked = False
Me.txtTelefoneContato24.Locked = False
Me.txtCelularContato24.Locked = False
Me.txtCargoContato24.Locked = False
Me.txtEmailContato24.Locked = False
Me.txtContato25.Locked = False
Me.txtTelefoneContato25.Locked = False
Me.txtCelularContato25.Locked = False
Me.txtCargoContato25.Locked = False
Me.txtEmailContato25.Locked = False
Me.txtAnotacoes1.Locked = False
Me.txtAnotacoes2.Locked = False
Me.txtAnotacoes3.Locked = False
Me.txtAnotacoes4.Locked = False
Me.txtAnotacoes5.Locked = False
Me.txtCodigoDoCliente.BackColor = corEnabledTextBox
Me.txtCliente.BackColor = corEnabledTextBox
Me.txtEndereco.BackColor = corEnabledTextBox
Me.txtBairro.BackColor = corEnabledTextBox
Me.txtCidade.BackColor = corEnabledTextBox
Me.txtUF.BackColor = corEnabledTextBox
Me.txtCep.BackColor = corEnabledTextBox
Me.txtPais.BackColor = corEnabledTextBox
Me.txtDDD1.BackColor = corEnabledTextBox
Me.txtTelefone1.BackColor = corEnabledTextBox
Me.txtDDD2.BackColor = corEnabledTextBox
Me.txtTelefone2.BackColor = corEnabledTextBox
Me.txtSite.BackColor = corEnabledTextBox
Me.txtCoordenador.BackColor = corEnabledTextBox
Me.txtRamalCoordenador.BackColor = corEnabledTextBox
Me.txtEmailCoordenador.BackColor = corEnabledTextBox
Me.txtCelularCoordenador.BackColor = corEnabledTextBox
Me.txtProjetista.BackColor = corEnabledTextBox
Me.txtRamalProjetista.BackColor = corEnabledTextBox
Me.txtEmailProjetista.BackColor = corEnabledTextBox
Me.txtCelularProjetista.BackColor = corEnabledTextBox
Me.txtVendedor.BackColor = corEnabledTextBox
Me.txtRamalVendedor.BackColor = corEnabledTextBox
Me.txtEmailVendedor.BackColor = corEnabledTextBox
Me.TxtCelularVendedor.BackColor = corEnabledTextBox
Me.txtGestor.BackColor = corEnabledTextBox
Me.txtRamalGestor.BackColor = corEnabledTextBox
Me.txtEmailGestor.BackColor = corEnabledTextBox
Me.txtCelularGestor.BackColor = corEnabledTextBox
Me.txtContato1.BackColor = corEnabledTextBox
Me.txtTelefoneContato1.BackColor = corEnabledTextBox
Me.txtCelularContato1.BackColor = corEnabledTextBox
Me.txtCargoContato1.BackColor = corEnabledTextBox
Me.txtEmailContato1.BackColor = corEnabledTextBox
Me.txtContato2.BackColor = corEnabledTextBox
Me.txtTelefoneContato2.BackColor = corEnabledTextBox
Me.txtCelularContato2.BackColor = corEnabledTextBox
Me.txtCargoContato2.BackColor = corEnabledTextBox
Me.txtEmailContato2.BackColor = corEnabledTextBox
Me.txtContato3.BackColor = corEnabledTextBox
Me.txtTelefoneContato3.BackColor = corEnabledTextBox
Me.txtCelularContato3.BackColor = corEnabledTextBox
Me.txtCargoContato3.BackColor = corEnabledTextBox
Me.txtEmailContato3.BackColor = corEnabledTextBox
Me.txtContato4.BackColor = corEnabledTextBox
Me.txtTelefoneContato4.BackColor = corEnabledTextBox
Me.txtCelularContato4.BackColor = corEnabledTextBox
Me.txtCargoContato4.BackColor = corEnabledTextBox
Me.txtEmailContato4.BackColor = corEnabledTextBox
Me.txtContato5.BackColor = corEnabledTextBox
Me.txtTelefoneContato5.BackColor = corEnabledTextBox
Me.txtCelularContato5.BackColor = corEnabledTextBox
Me.txtCargoContato5.BackColor = corEnabledTextBox
Me.txtEmailContato5.BackColor = corEnabledTextBox
Me.txtContato6.BackColor = corEnabledTextBox
Me.txtTelefoneContato6.BackColor = corEnabledTextBox
Me.txtCelularContato6.BackColor = corEnabledTextBox
Me.txtCargoContato6.BackColor = corEnabledTextBox
Me.txtEmailContato6.BackColor = corEnabledTextBox
Me.txtContato7.BackColor = corEnabledTextBox
Me.txtTelefoneContato7.BackColor = corEnabledTextBox
Me.txtCelularContato7.BackColor = corEnabledTextBox
Me.txtCargoContato7.BackColor = corEnabledTextBox
Me.txtEmailContato7.BackColor = corEnabledTextBox
Me.txtContato8.BackColor = corEnabledTextBox
Me.txtTelefoneContato8.BackColor = corEnabledTextBox
Me.txtCelularContato8.BackColor = corEnabledTextBox
Me.txtCargoContato8.BackColor = corEnabledTextBox
Me.txtEmailContato8.BackColor = corEnabledTextBox
Me.txtContato9.BackColor = corEnabledTextBox
Me.txtTelefoneContato9.BackColor = corEnabledTextBox
Me.txtCelularContato9.BackColor = corEnabledTextBox
Me.txtCargoContato9.BackColor = corEnabledTextBox
Me.txtEmailContato9.BackColor = corEnabledTextBox
Me.txtContato10.BackColor = corEnabledTextBox
Me.txtTelefoneContato10.BackColor = corEnabledTextBox
Me.txtCelularContato10.BackColor = corEnabledTextBox
Me.txtCargoContato10.BackColor = corEnabledTextBox
Me.txtEmailContato10.BackColor = corEnabledTextBox
Me.txtContato11.BackColor = corEnabledTextBox
Me.txtTelefoneContato11.BackColor = corEnabledTextBox
Me.txtCelularContato11.BackColor = corEnabledTextBox
Me.txtCargoContato11.BackColor = corEnabledTextBox
Me.txtEmailContato11.BackColor = corEnabledTextBox
Me.txtContato12.BackColor = corEnabledTextBox
Me.txtTelefoneContato12.BackColor = corEnabledTextBox
Me.txtCelularContato12.BackColor = corEnabledTextBox
Me.txtCargoContato12.BackColor = corEnabledTextBox
Me.txtEmailContato12.BackColor = corEnabledTextBox
Me.txtContato13.BackColor = corEnabledTextBox
Me.txtTelefoneContato13.BackColor = corEnabledTextBox
Me.txtCelularContato13.BackColor = corEnabledTextBox
Me.txtCargoContato13.BackColor = corEnabledTextBox
Me.txtEmailContato13.BackColor = corEnabledTextBox
Me.txtContato14.BackColor = corEnabledTextBox
Me.txtTelefoneContato14.BackColor = corEnabledTextBox
Me.txtCelularContato14.BackColor = corEnabledTextBox
Me.txtCargoContato14.BackColor = corEnabledTextBox
Me.txtEmailContato14.BackColor = corEnabledTextBox
Me.txtContato15.BackColor = corEnabledTextBox
Me.txtTelefoneContato15.BackColor = corEnabledTextBox
Me.txtCelularContato15.BackColor = corEnabledTextBox
Me.txtCargoContato15.BackColor = corEnabledTextBox
Me.txtEmailContato15.BackColor = corEnabledTextBox
Me.txtContato16.BackColor = corEnabledTextBox
Me.txtTelefoneContato16.BackColor = corEnabledTextBox
Me.txtCelularContato16.BackColor = corEnabledTextBox
Me.txtCargoContato16.BackColor = corEnabledTextBox
Me.txtEmailContato16.BackColor = corEnabledTextBox
Me.txtContato17.BackColor = corEnabledTextBox
Me.txtTelefoneContato17.BackColor = corEnabledTextBox
Me.txtCelularContato17.BackColor = corEnabledTextBox
Me.txtCargoContato17.BackColor = corEnabledTextBox
Me.txtEmailContato17.BackColor = corEnabledTextBox
Me.txtContato18.BackColor = corEnabledTextBox
Me.txtTelefoneContato18.BackColor = corEnabledTextBox
Me.txtCelularContato18.BackColor = corEnabledTextBox
Me.txtCargoContato18.BackColor = corEnabledTextBox
Me.txtEmailContato18.BackColor = corEnabledTextBox
Me.txtContato19.BackColor = corEnabledTextBox
Me.txtTelefoneContato19.BackColor = corEnabledTextBox
Me.txtCelularContato19.BackColor = corEnabledTextBox
Me.txtCargoContato19.BackColor = corEnabledTextBox
Me.txtEmailContato19.BackColor = corEnabledTextBox
Me.txtContato20.BackColor = corEnabledTextBox
Me.txtTelefoneContato20.BackColor = corEnabledTextBox
Me.txtCelularContato20.BackColor = corEnabledTextBox
Me.txtCargoContato20.BackColor = corEnabledTextBox
Me.txtEmailContato20.BackColor = corEnabledTextBox
Me.txtContato21.BackColor = corEnabledTextBox
Me.txtTelefoneContato21.BackColor = corEnabledTextBox
Me.txtCelularContato21.BackColor = corEnabledTextBox
Me.txtCargoContato21.BackColor = corEnabledTextBox
Me.txtEmailContato21.BackColor = corEnabledTextBox
Me.txtContato22.BackColor = corEnabledTextBox
Me.txtTelefoneContato22.BackColor = corEnabledTextBox
Me.txtCelularContato22.BackColor = corEnabledTextBox
Me.txtCargoContato22.BackColor = corEnabledTextBox
Me.txtEmailContato22.BackColor = corEnabledTextBox
Me.txtContato23.BackColor = corEnabledTextBox
Me.txtTelefoneContato23.BackColor = corEnabledTextBox
Me.txtCelularContato23.BackColor = corEnabledTextBox
Me.txtCargoContato23.BackColor = corEnabledTextBox
Me.txtEmailContato23.BackColor = corEnabledTextBox
Me.txtContato24.BackColor = corEnabledTextBox
Me.txtTelefoneContato24.BackColor = corEnabledTextBox
Me.txtCelularContato24.BackColor = corEnabledTextBox
Me.txtCargoContato24.BackColor = corEnabledTextBox
Me.txtEmailContato24.BackColor = corEnabledTextBox
Me.txtContato25.BackColor = corEnabledTextBox
Me.txtTelefoneContato25.BackColor = corEnabledTextBox
Me.txtCelularContato25.BackColor = corEnabledTextBox
Me.txtCargoContato25.BackColor = corEnabledTextBox
Me.txtEmailContato25.BackColor = corEnabledTextBox
Me.txtAnotacoes1.BackColor = corEnabledTextBox
Me.txtAnotacoes2.BackColor = corEnabledTextBox
Me.txtAnotacoes3.BackColor = corEnabledTextBox
Me.txtAnotacoes4.BackColor = corEnabledTextBox
Me.txtAnotacoes5.BackColor = corEnabledTextBox
End Sub
Private Sub DesabilitaControles()
'Me.txtCodigoDoCliente.Locked = True
Me.txtCliente.Locked = True
Me.txtContato1.Locked = True
'______________________________________________________
Me.txtCodigoDoCliente.BackColor = corDisabledTextBox
End Sub
Private Sub HabilitaBotoesAlteracao()
'habilita os botões de alteração
optAlterar.Enabled = True
optExcluir.Enabled = True
optNovo.Enabled = True
btnPesquisar.Enabled = True
btnOK.Enabled = False
btnCancelar.Enabled = False
'limpa os valores dos controles
optAlterar.Value = False
optExcluir.Value = False
optNovo.Value = False
End Sub
Private Sub DesabilitaBotoesAlteracao()
'desabilita os botões de alteração
optAlterar.Enabled = False
optExcluir.Enabled = False
optNovo.Enabled = False
btnPesquisar.Enabled = False
btnOK.Enabled = True
btnCancelar.Enabled = True
End Sub
Public Function ProcuraIndiceRegistroPodId(ByVal id As Long) As Long
Dim i As Long
Dim retorno As Long
Dim encontrado As Boolean
i = indiceMinimo
With wsCadastro
Do While Not IsEmpty(.Cells(i, colCodigoDoCliente))
If .Cells(i, colCodigoDoCliente).Value = id Then
retorno = i
encontrado = True
Exit Do
End If
i = i + 1
Loop
End With
'caso não encontre o registro, retorna -1
If Not encontrado Then
retorno = -1
End If
ProcuraIndiceRegistroPodId = i
End Function
Private Sub DefinePlanilhaDados()
Dim abrirArquivo As Boolean
Dim wb As Workbook
Dim caminhoCompleto As String
Dim ARQUIVO_DADOS As String
Dim PASTA_DADOS As String
abrirArquivo = True
ARQUIVO_DADOS = Range("ARQUIVO_DADOS").Value
PASTA_DADOS = Range("PASTA_DADOS").Value
If ThisWorkbook.Name <> ARQUIVO_DADOS Then
'monta a string do caminho completo
If PASTA_DADOS = vbNullString Or PASTA_DADOS = "" Then
caminhoCompleto = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, vbNullString) & ARQUIVO_DADOS
Else
If Right(PASTA_DADOS, 1) = "\" Then
caminhoCompleto = PASTA_DADOS & ARQUIVO_DADOS
Else
caminhoCompleto = PASTA_DADOS & "\" & ARQUIVO_DADOS
End If
End If
'verifica se o arquivo não está aberto
For Each wb In Application.Workbooks
If wb.Name = ARQUIVO_DADOS Then
abrirArquivo = False
Exit For
End If
Next
'atribui o arquivo
If abrirArquivo Then
Set wbCadastro = Workbooks.Open(Filename:=caminhoCompleto, ReadOnly:=True)
Else
Set wbCadastro = Workbooks(ARQUIVO_DADOS)
End If
Else
Set wbCadastro = ThisWorkbook
End If
Set wsCadastro = wbCadastro.Worksheets(nomePlanilhaCadastro)
'oculta o arquivo de dados
wbCadastro.Windows(1).Visible = False
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'fecha a planilha de dados, se estiver aberta
If Not wbCadastro Is Nothing Then
wbCadastro.Saved = True
wbCadastro.Close SaveChanges:=False
End If
Set wbCadastro = Nothing
End Sub