Fernando,
Na verdade são macros de duas userform's que acarretam nesse erro.
1° mysub (eu exclui esse código, e o erro, lógico, sumiu, aparecendo apenas se eu abri a userform19.)
2° Eu não sei qual macro é, mas sei que é alguma da userform19, pois se eu não abrir essa userform, o erro não acontece.
Macros da userform19:
Dim tamanhoLargura, tamanhoAltura
Option Explicit
'listrado
Private Declare Function SetWindowLong& Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long _
, ByVal wCmd As Long) As Long
Private Const GWL_WNDPROC As Long = (-4&)
Private hwnd As Long
'icone
Private Declare Function ExibirÍcone Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
' o termo FindWindwA não pode ser alterado
'// Constante do Ícone
Private Const FOCO_ICONE = &H80
Private Const ICONE = 0&
'tamanho das colunas
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const LVM_FIRST = &H1000
Private Const LVM_SETCOLUMNWIDTH = (LVM_FIRST + 30)
Private Const LVSCW_AUTOSIZE = -1
Private Const LVSCW_AUTOSIZE_USEHEADER = -2
Dim Form_Personalizado As Long
Dim hIcone As Long
Dim mclsFormChanger As CFormChanger
Dim nAtualizaForm As New Classeform
Private Const imprimir As String = "Relatorio"
Private Const NomeDaPlanilha As String = "cliente"
Private Const LinhaCabecalho As Integer = 1
'define constantes para controlar as colunas de dados
Const colcodigo As Integer = 1
Const colcliente As Integer = 2
Const colccusto As Integer = 3
Const colcrazão As Integer = 4
Const coltipo As Integer = 5
Const colsoma As Integer = 18
Const colmédia As Integer = 19
Const colentrada As Integer = 20
Const colsaída As Integer = 21
Const coltelefone As Integer = 22
Const colemail As Integer = 23
Const indiceMinimo As Byte = 2
'define variavies para controlar a
Private alterar As Boolean
Private novo As Boolean
Private excluir As Boolean
'define as constantes para as cores do textbox
Const corDesabilitaTextBox As Long = -2147483633
Const corHabilitaTextBox As Long = -2147483643
'define a planilha usada e o indice do registro
Private CadastroProdutos As Worksheet
Private indiceRegistro As Long
Private Sub combobox2_Change()
If ComboBox2.Text <> "" Then
Image65.Visible = True
Image67.Visible = False
End If
End Sub
Private Sub ComboBox2_Enter()
If ComboBox2.Text <> "" Then
Image65.Visible = True
Image67.Visible = False
End If
End Sub
Private Sub ComboBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Image67.Visible = True
Image65.Visible = False
End Sub
Private Sub ComboBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Image65.Visible = True
Image67.Visible = False
End Sub
Private Sub ComboBoxCampos_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = 0
End Sub
Private Sub Frame17_Click()
TextBox59.Text = "tel"
Me.Hide
UserForm81.Show
End Sub
Private Sub Frame17_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Frame17.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Frame18_Click()
End Sub
Private Sub Frame18_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Frame18.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image22_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image22.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image23_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image23.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image24_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image24.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image25_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image25.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image26_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image26.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image27_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image27.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image28_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image28.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image28_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image28.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image29_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image29.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image30_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image30.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image31_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image31.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image32_Click()
Shell "calc.exe"
End Sub
Private Sub Image59_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image59.SpecialEffect = fmSpecialEffectSunken
If txtproduto.Text = "" Then
Image59.ControlTipText = "Você ainda não selecionou um Cliente!"
Else
Image59.ControlTipText = "Insira-o na programação que você está fazendo!"
End If
End Sub
Private Sub CommandButton3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Label43.Visible = True
End Sub
Private Sub Image66_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image66.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image68_Click()
On Error Resume Next
If txtproduto.Text = "" Then
MsgBox "Gentileza selecionar um cliente!", vbCritical, "Atenção!"
Exit Sub
End If
Dim lastRow As Object
Sheets("GRAFICO_CLIENTE").Select
Set lastRow = Plan30.Range("a1:a1").End(xlUp)
lastRow.Offset(0, 0).Value = txtCodigo.Text
ThisWorkbook.Worksheets("GRAFICO_CLIENTE").Activate
Me.Hide
UserForm80.Show
End Sub
Private Sub Image32_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image32.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Image65_Click()
If ComboBox2.Text = "" Then
MsgBox "Por favor, selecione o ano a ser pesquisado e Tente Novamente!", vbInformation, "Atenção!"
ComboBox2.SetFocus
Exit Sub
End If
If Label41.Caption = ComboBox2.Text Then
MsgBox "Os dados referentes a este ano estão carregados! Selecione outro ano e Tente Novamente!", vbInformation, "Atenção!"
Exit Sub
End If
Sheets("cliente").Select
Dim lastRow As Object
Set lastRow = Plan22.Range("z:z").End(xlUp)
lastRow.Offset(0, 0).Value = ComboBox2.Value
Call PreencherCabeçalhoLinhas
Call formatação_lsLista
Call formato_islista
Image28.Enabled = False
novo = False
alterar = False
excluir = False
Set CadastroProdutos = ThisWorkbook.Worksheets("cliente")
Call HabilitaBotoesAlteracao
Call carregaDados
Call DesabilitaControles
Call LimpaControles
Call atualizar
Label41.Caption = ComboBox2.Text
If TextBoxFiltro.Text <> "" Then
Call TextBoxFiltro_Change
Call TamanhoColAutomatico
MsgBox "Pesquisa realizada com sucesso!", vbInformation, "Atenção!"
Exit Sub
End If
If TextBoxFiltro.Text = "" Then
Call TamanhoColAutomatico
MsgBox "Pesquisa realizada com sucesso!", vbInformation, "Atenção!"
Exit Sub
End If
End Sub
Private Sub Label39_Click()
End Sub
Private Sub Image68_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image68.SpecialEffect = fmSpecialEffectSunken
End Sub
Private Sub Label57_Click()
Shell "calc.exe"
End Sub
Private Sub Lslista_ItemCheck(ByVal Item As MSComctlLib.ListItem)
Label104.Visible = True
Label96.Visible = True
Call Somar2
Dim j As Integer
If Item.Checked = True Then
Item.ForeColor = RGB(0, 0, 255) 'Changement couleur
'Item.Bold = True 'Gras
Item.Selected = True
For j = 1 To Item.ListSubItems.Count
Item.ListSubItems(j).ForeColor = RGB(0, 0, 255)
'Item.ListSubItems(j).Bold = True
Item.Selected = True
Next j
Else
Item.ForeColor = RGB(1, 0, 0) 'Changement couleur
Item.Bold = False
Item.Selected = False
For j = 1 To Item.ListSubItems.Count
Item.ListSubItems(j).ForeColor = RGB(1, 0, 0)
Item.ListSubItems(j).Bold = False
Item.Selected = False
Next j
End If
End Sub
Private Sub lslista_KeyDown(KeyCode As Integer, ByVal Shift As Integer)
Select Case KeyCode
Case vbKeyDelete
Call image22_Click
End Select
Select Case KeyCode
Case vbKeyF12 And TextBox34.Text = 1
Unload Me
UserForm9.Hide
End Select
End Sub
Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)
End Sub
Private Sub TextBox32_Change()
TextBox32 = Format(TextBox32, "Currency")
End Sub
Private Sub TextBox35_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
End Sub
Private Sub TextBox35_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = 0
If TextBox35.Locked = False Then
TextBox35.Text = ""
UserForm81.Show
End If
End Sub
Private Sub TextBox35_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Frame17.SpecialEffect = fmSpecialEffectRaised
End Sub
Private Sub TextBox36_Change()
End Sub
Private Sub TextBox36_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Frame18.SpecialEffect = fmSpecialEffectRaised
End Sub
Private Sub TextBox58_Change()
If TextBox58.Text = 0 Then
Frame5.Visible = False
Call OcultaColunas
Call TamanhoColAutomatico
End If
End Sub
Private Sub TextBoxFiltro_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Call OcultaColunas
Call TamanhoColAutomatico
Label10.Visible = False
Dim StringLength
StringLength = Len(TextBoxFiltro.Text)
[TextBox58] = StringLength - 1
End Sub
Private Sub TextBoxFiltro_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim StringLength
If TextBox34.Text = "1" Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image66.Visible = True
Image31.Visible = False
Label10.Visible = True
Call LimpaControles
StringLength = Len(TextBoxFiltro.Text)
[TextBox58] = StringLength + 1
End If
End Sub
Private Sub Somar2()
Dim valor2 As Double
Dim valor3 As Double
Dim i
For i = 1 To lslista.ListItems.Count
If lslista.ListItems.Item(i).Checked = False Then
Frame5.Visible = True
Else
On Error Resume Next
valor2 = valor2 + CDbl(Me.lslista.ListItems(i).ListSubItems(19))
valor3 = valor3 + CDbl(Me.lslista.ListItems(i).ListSubItems(20))
End If
Next i
Label104.Caption = valor2
Label96.Caption = valor3
Label105.Caption = Format(Label96.Caption / TextBox54.Value, "0.00%")
Label106.Caption = Format(Label104.Caption / TextBox57.Value, "0.00%")
End Sub
Private Sub UserForm_Activate()
Application.OnKey "{Escape}", ""
Set nAtualizaForm.Form = Me
Form_Personalizado = FindWindowA(vbNullString, Me.Caption)
Call ExibirÍcone(Form_Personalizado, FOCO_ICONE, ICONE, ByVal hIcone)
Set mclsFormChanger = New CFormChanger
Set mclsFormChanger.Form = Me
mclsFormChanger.ShowTaskBarIcon = True
Call TamanhoColAutomatico
Call OcultaColunas
Label41.Caption = [af1]
hIcone = Image5.Picture.Handle
Form_Personalizado = FindWindowA(vbNullString, Me.Caption)
Call ExibirÍcone(Form_Personalizado, FOCO_ICONE, ICONE, ByVal hIcone)
Set mclsFormChanger = New CFormChanger
Set mclsFormChanger.Form = Me
mclsFormChanger.ShowTaskBarIcon = True
If TextBox34.Text = 1 Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = True
Image31.Visible = False
Exit Sub
End If
If TextBox34.Text = 2 Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = False
Image31.Visible = False
Exit Sub
End If
If TextBox34.Text = 5 Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = False
Image31.Visible = False
Exit Sub
End If
If TextBox34.Text = 3 Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = False
Image31.Visible = False
Exit Sub
End If
If TextBox34.Text = 6 Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = False
Image31.Visible = False
Exit Sub
End If
End Sub
Private Sub TamanhoColAutomatico()
Dim Column As Long
Dim Counter As Long
Counter = 0
For Column = Counter To lslista.ColumnHeaders.Count - 2
SendMessage lslista.hwnd, LVM_SETCOLUMNWIDTH, Column, LVSCW_AUTOSIZE_USEHEADER
Next
Call OcultaColunas
End Sub
Private Sub btnOK_Click()
UserForm7.Show
End Sub
Sub formatação_lsLista()
With lslista
.View = lvwReport
.Gridlines = True
.Appearance = 1 '= 0 - ccFlat e 1- cc3d
.Arrange = 0 '= 0 lvwNome / 1 lvwautoleft / 2 lvwautotop
.CheckBoxes = True '= true ou false
'.ControlTipText =
.Enabled = True ' true ou false
.FlatScrollBar = False '= true ou false
.FullRowSelect = True ' = true ou false
.Gridlines = True '= true ou false
' .Height
'.HelpContextID
.HideColumnHeaders = False ' = true ou false
'.HideSelction = True '= true ou false
.HotTracking = False '= true ou false
.HoverSelection = False '= true ou false
.LabelEdit = 1 '= 0 lvw automatic ou 1 - lvwmanual
.LabelWrap = True ' = true ou false
.MultiSelect = False '= true ou false
.OLEDragMode = ccOLEDragManual
End With
End Sub
Private Sub OcultaColunas()
On Error Resume Next
With lslista
.ColumnHeaders(20).Width = 0
.ColumnHeaders(21).Width = 0
.ColumnHeaders(22).Width = 0
.ColumnHeaders(23).Width = 0
.ColumnHeaders(24).Width = 0
.ColumnHeaders(25).Width = 0
.ColumnHeaders(26).Width = 0
.ColumnHeaders(27).Width = 0
.ColumnHeaders(28).Width = 0
End With
End Sub
Private Sub cbModal_Change()
nAtualizaForm.Modal = cbModal.Value
End Sub
Private Sub Image28_Click()
Application.OnKey "{Escape}", ""
TextBox37.Text = TextBox35.Text
alterar = True
Application.Visible = False
If txtCodigo.Text <> vbNullString And txtCodigo.Text <> "" Then
txtCodigo.Enabled = True
Call HabilitaControles
Call DesabilitaBotoesAlteracao
'dá o foco ao primeiro controle de dados
txtproduto.SetFocus
Image28.Visible = False
Frame17.Visible = True
Frame18.Visible = True
lslista.Enabled = False
Else
MsgBox "Não há registro a ser alterado"
TextBoxFiltro = ""
ComboBoxCampos = ""
Frame17.Visible = False
Frame18.Visible = False
End If
End Sub
Sub trocar()
txtCodigo.Enabled = True
Call HabilitaControles
Call DesabilitaBotoesAlteracao
'dá o foco ao primeiro controle de dados
txtproduto.SetFocus
Image28.Visible = False
Frame17.Visible = True
Frame18.Visible = True
lslista.Enabled = False
TextBox59.Text = ""
End Sub
Private Sub Image24_Click()
Application.OnKey "{Escape}", ""
If TextBox34.Text = 1 Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = True
Image31.Visible = False
Frame17.Visible = False
Frame18.Visible = False
Call arrumar
lslista.Enabled = True
Exit Sub
End If
If TextBox34.Text = 2 Then
Frame17.Visible = False
Frame18.Visible = False
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = False
Image31.Visible = False
lslista.Enabled = True
Call arrumar
Exit Sub
End If
If TextBox34.Text = 3 Then
Frame17.Visible = False
Frame18.Visible = False
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = False
Image31.Visible = False
lslista.Enabled = True
Call arrumar
Exit Sub
End If
End Sub
Sub arrumar()
Sheets("cliente").Select
Cells.Select
Cells.EntireColumn.AutoFit
TextBoxFiltro.SetFocus
Call PreencheCampos
Me.ComboBoxCampos.ListIndex = 1
PreencherListView
Call PreencherCabeçalhoLinhas
Call formatação_lsLista
Image28.Enabled = False
novo = False
alterar = False
excluir = False
Set CadastroProdutos = ThisWorkbook.Worksheets("cliente")
Call HabilitaBotoesAlteracao
Call carregaDados
Call DesabilitaControles
Call LimpaControles
Call atualizar
Call TamanhoColAutomatico
Call formato_islista
End Sub
Private Sub image22_Click()
Application.OnKey "{Escape}", ""
If txtCodigo.Text = "1" Then
MsgBox "Este registro é padrão do sistema e não aceita exclusão!", vbInformation, "Padrão"
Exit Sub
End If
Application.Visible = False
excluir = True
If txtCodigo.Text <> vbNullString And txtCodigo.Text <> "" Then
Call DesabilitaBotoesAlteracao
'MsgBox "Você confirma a exclusão deste registro. (Para excluir clique no botão OK.) "
Else
MsgBox "Não existe registro a ser excluído", , "Cadastro"
Exit Sub
End If
Dim RESULTADO As VbMsgBoxResult
RESULTADO = MsgBox("Deseja excluir o registro nº " & txtCodigo.Text & " ?", vbYesNo, "Confirmação")
If RESULTADO = vbYes Then
CadastroProdutos.Range(CadastroProdutos.Cells(indiceRegistro, colcodigo), CadastroProdutos.Cells(indiceRegistro, colcodigo)).EntireRow.Delete
MsgBox "O Registro escolhido foi excluído com sucesso.", , "Cadastro"
txtCodigo.Enabled = False
Call LimpaControles
Call TextBoxFiltro_Change
Call TamanhoColAutomatico
If TextBox34.Text = 1 Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = True
Image31.Visible = False
Exit Sub
End If
If TextBox34.Text = 2 Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = False
Image31.Visible = False
Exit Sub
End If
If TextBox34.Text = 3 Then
Image22.Visible = True
Image25.Visible = True
Image26.Visible = True
Image27.Visible = True
Image29.Visible = True
Image66.Visible = False
Image31.Visible = False
Exit Sub
End If
End If
Exit Sub
End Sub
Private Sub Image30_Click()
Application.OnKey "{Escape}", ""
Application.Visible = False
Dim proximoId As Long
Dim controle As Control
Dim str As String
Dim chk As TextBox
For Each controle In Me.Controls
If TypeName(controle) = "textbox" Then
str = str & controle.Caption & ","
End If
Next
UserForm20.TextBox19 = UserForm19.TextBox34 & str
UserForm19.Hide
UserForm20.Show
End Sub
Private Sub Image23_Click()
If txtproduto.Text = "" Then
MsgBox "Por favor, selecione um Cliente/fornecedor e tente novamente!", vbInformation, "Atenção!"
Exit Sub
End If
Application.OnKey "{Escape}", ""
Application.Visible = False
If alterar = True Then
Call SalvaRegistro(CDbl(txtCodigo.Text), indiceRegistro)
MsgBox "O Registro alterado com sucesso.", , "Cadastro"
txtCodigo.Enabled = False
Call PreencherCabeçalhoLinhas
Call LimpaControles
Call atualizar
Call DesabilitaControles
Call DesabilitaBotoesAlteracao
Image27.Visible = True
Image26.Visible = True
Call LimpaControles
Call TextBoxFiltro_Change
Call TamanhoColAutomatico
lslista.Enabled = True
Exit Sub
End If
End Sub
Private Sub SalvaRegistro(ByVal id As Long, ByVal Indice As Long)
With CadastroProdutos
Dim linha, Index
Dim i As Integer
Dim indiceRegistro As Long
Dim oList As Object
Dim j
On Error Resume Next
Set oList = lslista.SelectedItem
If oList Is Nothing Then
Exit Sub
End If
.Cells(Indice, colcodigo).Value = id
.Cells(Indice, colcliente).Value = Me.txtproduto.Text
.Cells(Indice, colcrazão).Value = Me.txtunidade.Text
.Cells(Indice, coltipo).Value = Me.txtvalorp.Text
.Cells(Indice, colccusto).Value = Me.TextBox1.Text
.Cells(Indice, coltelefone).Value = Me.TextBox35.Text
.Cells(Indice, colemail).Value = Me.TextBox36.Text
End With
Call AtualizaRegistroAtual
End Sub
Private Sub CarregaRegistro()
'carrega os dados do primeiro registro
With CadastroProdutos
If Not IsEmpty(.Cells(indiceRegistro, colcliente)) Then
Me.txtCodigo.Text = .Cells(indiceRegistro, colcodigo).Value
Me.txtproduto.Text = .Cells(indiceRegistro, colcliente).Value
Me.txtunidade.Text = .Cells(indiceRegistro, colcrazão).Value
Me.txtvalorp.Text = .Cells(indiceRegistro, coltipo).Value
Me.TextBox1.Text = .Cells(indiceRegistro, colccusto).Value
Me.TextBox32.Text = .Cells(indiceRegistro, colsoma).Value
Me.TextBox35.Text = .Cells(indiceRegistro, coltelefone).Value
Me.TextBox36.Text = .Cells(indiceRegistro, colemail).Value
End If
End With
Call AtualizaRegistroAtual
End Sub
Private Sub carregaDados()
indiceRegistro = 2
Call CarregaRegistro
End Sub
Private Sub AtualizaRegistroAtual()
lblRegistro.Caption = indiceRegistro - 1 & " de " & CadastroProdutos.UsedRange.Rows.Count - 1
'lblMensagem.Caption = ""
End Sub
Private Function ObterProximoId() As Long
Dim rangeIds As Range
'pega o range que se refere a toda a coluna do código (id)
Set rangeIds = CadastroProdutos.Range(CadastroProdutos.Cells(indiceMinimo, colcodigo), CadastroProdutos.Cells(CadastroProdutos.UsedRange.Rows.Count, colcodigo))
ObterProximoId = WorksheetFunction.max(rangeIds) + 1
End Function
Private Sub CarregaProdutos(ByVal Categoria As String)
Dim linha As Integer, colunaproduto As Integer, colunaCategoria As Integer
linha = 2
colunaproduto = 1
colunaCategoria = 2
With Sheets("Produtos")
Do While Not IsEmpty(.Cells(linha, colunaproduto))
If .Cells(linha, colunaCategoria).Value = Categoria Then
End If
linha = linha + 1
Loop
End With
End Sub
Private Sub CommandButton1_Click()
Application.OnKey "{Escape}", ""
Application.Visible = False
Unload Me
Unload frmComboBoxEncadeado
End Sub
Private Sub Image59_Click()
Application.OnKey "{Escape}", ""
If TextBox34.Text = 1 Then
MsgBox "Identifiquei que, no momento, nenhuma programação encontra-se em andamento e, por conta disso, a opção de Selecionar não está ativa!", vbInformation, "Atenção!"
Image59.Enabled = False
Exit Sub
End If
Application.Visible = False
If txtproduto.Text = "" Then
MsgBox "Gentileza selecionar um cliente!", vbCritical, "Atenção!"
Exit Sub
End If
If TextBox34.Text = 2 Then
Dim proximoId As Long
Dim controle As Control
Dim str As String
Dim chk As TextBox
For Each controle In Me.Controls
If TypeName(controle) = "textbox" Then
str = str & controle.Caption & ","
End If
Next
frmComboBoxEncadeado.TextBox18 = UserForm19.txtproduto & str
frmComboBoxEncadeado.TextBox20 = UserForm19.TextBox1 & str
frmComboBoxEncadeado.TextBox21 = UserForm19.txtunidade & str
frmComboBoxEncadeado.TextBox22 = UserForm19.txtvalorp & str
frmComboBoxEncadeado.TextBox23 = UserForm19.txtCodigo & str
frmComboBoxEncadeado.entrou
Unload Me
frmComboBoxEncadeado.Show
Sheets("real").Select
Exit Sub
End If
If TextBox34.Text = 3 Then
For Each controle In Me.Controls
If TypeName(controle) = "textbox" Then
str = str & controle.Caption & ","
End If
Next
frmComboBoxEncadeado.TextBox18 = UserForm19.txtproduto & str
frmComboBoxEncadeado.TextBox20 = UserForm19.TextBox1 & str
frmComboBoxEncadeado.TextBox21 = UserForm19.txtunidade & str
frmComboBoxEncadeado.TextBox22 = UserForm19.txtvalorp & str
frmComboBoxEncadeado.TextBox23 = UserForm19.txtCodigo & str
If frmComboBoxEncadeado.TextBox1.Text = "" Then
frmComboBoxEncadeado.TextBox1.SetFocus
End If
If frmComboBoxEncadeado.TextBox1.Text <> "" And frmComboBoxEncadeado.TextBox19.Text = "" Then
On Error Resume Next
frmComboBoxEncadeado.TextBox19.SetFocus
frmComboBoxEncadeado.TextBox19.BackColor = &H80000018
End If
If frmComboBoxEncadeado.TextBox1.Text <> "" Then
On Error Resume Next
frmComboBoxEncadeado.TextBox19.SetFocus
frmComboBoxEncadeado.TextBox19.BackColor = &H80000018
End If
frmComboBoxEncadeado.entrou
Unload Me
frmComboBoxEncadeado.Show
Sheets("real").Select
Exit Sub
End If
If TextBox34.Text = 5 Then
For Each controle In Me.Controls
If TypeName(controle) = "textbox" Then
str = str & controle.Caption & ","
End If
Next
UserForm9.TextBox38 = UserForm19.txtproduto & str
UserForm9.TextBox1 = UserForm19.TextBox1 & str
UserForm9.txtunidade = UserForm19.txtunidade & str
UserForm9.txtvalorp = UserForm19.txtvalorp & str
UserForm9.txtCodigo = UserForm19.txtCodigo & str
Unload Me
UserForm9.Show
Sheets("real").Select
Exit Sub
End If
If TextBox34.Text = 6 Then
For Each controle In Me.Controls
If TypeName(controle) = "textbox" Then
str = str & controle.Caption & ","
End If
Next
UserForm46.TextBox18 = UserForm19.txtproduto & str
UserForm46.TextBox20 = UserForm19.TextBox1 & str
UserForm46.TextBox21 = UserForm19.txtunidade & str
UserForm46.TextBox25 = UserForm19.txtvalorp & str
UserForm46.TextBox26 = UserForm19.txtCodigo & str
Unload Me
UserForm46.Show
Exit Sub
End If
End Sub
Private Sub CommandButton3_Click()
Shell "calc.exe"
Label43.Visible = True
End Sub
Private Sub Label23_Click()
Dim iLin As Integer
Dim rgCellInicio As Range
Dim wsRelat As Worksheet
Dim UltimaLinha As Long
Set wsRelat = ThisWorkbook.Worksheets(imprimir)
UltimaLinha = wsRelat.UsedRange.Rows.Count
wsRelat.Range("A2:" & "o" & UltimaLinha).ClearContents
Set rgCellInicio = wsRelat.Range("A65536").End(xlUp).Offset(1, 0)
'recuperar dados
Dim i As Integer, j As Integer
'Loop nas linhas
For i = 1 To lslista.ListItems.Count
iLin = iLin + 1
rgCellInicio.Cells(iLin, 1).Value = lslista.ListItems(i).Text
'Loop nas colunas
For j = 1 To lslista.ColumnHeaders.Count - 1
rgCellInicio.Cells(iLin, j + 1).Value = lslista.ListItems(i).ListSubItems(j).Text
Next j
Next i
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
Cells.Select
Cells.EntireColumn.AutoFit
End With
Sheets("relatorio").Select
Unload Me
End Sub
Private Sub Label24_Click()
Dim iLin As Integer
Dim rgCellInicio As Range
Dim wsRelat As Worksheet
Dim UltimaLinha As Long
Set wsRelat = ThisWorkbook.Worksheets(imprimir)
UltimaLinha = wsRelat.UsedRange.Rows.Count
wsRelat.Range("A2:" & "o" & UltimaLinha).ClearContents
Set rgCellInicio = wsRelat.Range("A65536").End(xlUp).Offset(1, 0)
'recuperar dados
Dim i As Integer, j As Integer
'Loop nas linhas
For i = 1 To lslista.ListItems.Count
iLin = iLin + 1
rgCellInicio.Cells(iLin, 1).Value = lslista.ListItems(i).Text
'Loop nas colunas
For j = 1 To lslista.ColumnHeaders.Count - 1
rgCellInicio.Cells(iLin, j + 1).Value = lslista.ListItems(i).ListSubItems(j).Text
Next j
Next i
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
Cells.Select
Cells.EntireColumn.AutoFit
End With
wsRelat.Activate
Macro1
Macro3
Macro2
End Sub
Private Sub Label9_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Label23.Visible = True
Label24.Visible = True
End Sub
Private Sub lslista_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As stdole.OLE_XPOS_PIXELS, ByVal Y As stdole.OLE_YPOS_PIXELS)
End Sub
Private Sub txtproduto_Change()
txtproduto = UCase(txtproduto)
End Sub
Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
UserForm19.Hide
If TextBox34 = 1 Then
Unload Me
UserForm9.Show
Exit Sub
End If
If TextBox34 = 2 Then
'menu iniciar
Unload Me
UserForm7.Show
Exit Sub
End If
If TextBox34 = 3 Then
'menu iniciar
Unload Me
frmComboBoxEncadeado.Show
Exit Sub
End If
If TextBox34 = 4 Then
Unload Me
UserForm12.Show
Exit Sub
End If
If TextBox34 = 5 Then
'menu iniciar
Unload Me
UserForm9.Show
Exit Sub
End If
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Image30.SpecialEffect = fmSpecialEffectRaised
Image28.SpecialEffect = fmSpecialEffectRaised
Image22.SpecialEffect = fmSpecialEffectRaised
Image23.SpecialEffect = fmSpecialEffectRaised
Image24.SpecialEffect = fmSpecialEffectRaised
Image32.SpecialEffect = fmSpecialEffectRaised
Frame17.SpecialEffect = fmSpecialEffectRaised
Image66.SpecialEffect = fmSpecialEffectRaised
Image25.SpecialEffect = fmSpecialEffectRaised
Image29.SpecialEffect = fmSpecialEffectRaised
Image31.SpecialEffect = fmSpecialEffectRaised
Image26.SpecialEffect = fmSpecialEffectRaised
Image27.SpecialEffect = fmSpecialEffectRaised
Image68.SpecialEffect = fmSpecialEffectRaised
Image59.SpecialEffect = fmSpecialEffectRaised
Frame18.SpecialEffect = fmSpecialEffectRaised
If TextBox59.Text = "tel" Then
Call trocar
End If
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
UserForm19.Hide
If TextBox34 = 1 Then
Unload Me
UserForm9.Show
Exit Sub
End If
If TextBox34 = 2 Then
'menu iniciar
Unload Me
Unload UserForm19
UserForm7.Show
Exit Sub
End If
If TextBox34 = 3 Then
'menu iniciar
Unload Me
frmComboBoxEncadeado.Show
Exit Sub
End If
If TextBox34 = 4 Then
Unload Me
UserForm12.Show
Exit Sub
End If
If TextBox34 = 5 Then
'menu iniciar
Unload Me
UserForm9.Show
Exit Sub
End If
End If
End Sub
Private Sub UserForm_Initialize()
Application.OnKey "{Escape}", ""
Dim i&
hwnd = GetWindow(FindWindow(vbNullString, Me.Caption), 5)
OldProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindowProc)
Label41.Caption = [af1]
TextBox32.Text = ""
With Me
.Top = Application.Top
.Left = Application.Left
.Height = Application.Height
.Width = Application.Width
ComboBox2.AddItem "2015"
ComboBox2.AddItem "2014"
ComboBox2.AddItem "2013"
UserForm19.Caption = "Clientes Cadastrados."
Sheets("cliente").Select
If [x1] < 2 Then
userform27.Show
Exit Sub
End If
Cells.Select
Cells.EntireColumn.AutoFit
TextBoxFiltro.SetFocus
Call PreencheCampos
Me.ComboBoxCampos.ListIndex = 1
Call PreencherCabeçalhoLinhas
Call formatação_lsLista
Image28.Enabled = False
novo = False
alterar = False
excluir = False
Set CadastroProdutos = ThisWorkbook.Worksheets("cliente")
Call HabilitaBotoesAlteracao
Call carregaDados
Call DesabilitaControles
Call LimpaControles
Call formatação_lsLista
Call somar
End With
End Sub
Sub ajeitar()
Sheets("cliente").Select
Cells.Select
Cells.EntireColumn.AutoFit
TextBoxFiltro.SetFocus
Call PreencheCampos
Me.ComboBoxCampos.ListIndex = 1
PreencherListView
Call PreencherCabeçalhoLinhas
Call formatação_lsLista
Image28.Enabled = False
novo = False
alterar = False
excluir = False
Set CadastroProdutos = ThisWorkbook.Worksheets("cliente")
Call HabilitaBotoesAlteracao
Call carregaDados
Call DesabilitaControles
Call LimpaControles
Call atualizar
Call TamanhoColAutomatico
Call formato_islista
End Sub
Private Sub CarregaCategorias()
Dim linha As Integer, coluna As Integer
linha = 1
coluna = 5
Me.ComboBox2.Clear
With Sheets("cliente")
Do While Not IsEmpty(.Cells(linha, coluna))
Me.ComboBox2.AddItem .Cells(linha, coluna).Value
linha = linha + 1
Loop
End With
End Sub
Private Sub cmdPrimeiro_Click()
indiceRegistro = indiceMinimo
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub cmdProximo_Click()
If indiceRegistro < CadastroProdutos.UsedRange.Rows.Count Then
indiceRegistro = indiceRegistro + 1
End If
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub cmdUltimo_Click()
indiceRegistro = CadastroProdutos.UsedRange.Rows.Count
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub Image1_Click()
indiceRegistro = indiceMinimo
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub Image2_Click()
If indiceRegistro > indiceMinimo Then
indiceRegistro = indiceRegistro - 1
End If
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub Image3_Click()
If indiceRegistro < CadastroProdutos.UsedRange.Rows.Count Then
indiceRegistro = indiceRegistro + 1
End If
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub Image4_Click()
indiceRegistro = CadastroProdutos.UsedRange.Rows.Count
If indiceRegistro > 1 Then
Call CarregaRegistro
End If
End Sub
Private Sub Label11_Click()
PDF
End Sub
Private Sub Label7_Click()
Unload UserForm19
Application.WindowState = xlMinimized
Application.WindowState = xlMaximized
Plan22.Select
Application.Visible = True
End Sub
Private Sub Label8_Click()
ActiveWorkbook.Save
Application.Quit
Unload UserForm19
End Sub
Private Sub Label9_Click()
Dim iLin As Integer
Dim rgCellInicio As Range
Dim wsRelat As Worksheet
Dim UltimaLinha As Long
Set wsRelat = ThisWorkbook.Worksheets(imprimir)
UltimaLinha = wsRelat.UsedRange.Rows.Count
wsRelat.Range("A2:" & "o" & UltimaLinha).ClearContents
Set rgCellInicio = wsRelat.Range("A65536").End(xlUp).Offset(1, 0)
'recuperar dados
Dim i As Integer, j As Integer
'Loop nas linhas
For i = 1 To lslista.ListItems.Count
iLin = iLin + 1
rgCellInicio.Cells(iLin, 1).Value = lslista.ListItems(i).Text
'Loop nas colunas
For j = 1 To lslista.ColumnHeaders.Count - 1
rgCellInicio.Cells(iLin, j + 1).Value = lslista.ListItems(i).ListSubItems(j).Text
Next j
Next i
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
Cells.Select
Cells.EntireColumn.AutoFit
End With
wsRelat.Activate
Macro3
Macro2
End Sub
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
Dim i
For i = 1 To lslista.ListItems.Count
If lslista.ListItems.Item(i).Checked = False Then
lslista.ListItems.Item(i).Checked = True
Call Somar2
End If
Next i
Exit Sub
End If
If CheckBox1.Value = False Then
For i = 1 To lslista.ListItems.Count
If lslista.ListItems.Item(i).Checked = True Then
lslista.ListItems.Item(i).Checked = False
Call Somar2
End If
Next i
Exit Sub
End If
If CheckBox1.Value = "" Then
For i = 1 To lslista.ListItems.Count
If lslista.ListItems.Item(i).Checked = True Then
lslista.ListItems.Item(i).Checked = False
Call Somar2
End If
Next i
Exit Sub
End If
End Sub
Private Sub somar()
Dim i As Long
Dim valor2 As Double
Dim valor3 As Double
On Error Resume Next
For i = 1 To Me.lslista.ListItems.Count
On Error Resume Next
valor2 = valor2 + CDbl(Me.lslista.ListItems(i).ListSubItems(19))
valor3 = valor3 + CDbl(Me.lslista.ListItems(i).ListSubItems(20))
Next i
TextBox57.Text = valor2
TextBox54.Text = valor3
Frame5.Visible = True
Call OcultaColunas
End Sub
Private Sub lslista_Click()
Dim linha, Index
Dim i As Integer
Dim indiceRegistro As Long
Dim oList As Object
Dim j
On Error Resume Next
Set oList = lslista.SelectedItem
If oList Is Nothing Then
Exit Sub
End If
indiceRegistro = UserForm19.ProcuraIndiceRegistroPodId(lslista.ListItems.Item(lslista.SelectedItem.Index))
If indiceRegistro <> -1 Then
Call UserForm19.CarregaRegistroPorIndice(indiceRegistro)
End If
If TextBox34.Text = "1" Then
Image22.Enabled = True
Image25.Visible = False
Image22.Visible = True
Exit Sub
End If
If TextBox34.Text = 2 Then
Image22.Enabled = True
Image25.Visible = False
Image22.Visible = True
Exit Sub
End If
End Sub
Private Sub lsLista_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
On Error Resume Next
Dim vbHourglass
Dim InvNumber
' Começa ordenar o listview pela coluna clicada
With lslista
' Display the hourglass cursor whilst sorting
Dim lngCursor As Long
lngCursor = .MousePointer
.MousePointer = vbHourglass
' Prevent the ListView control from updating on screen -
' this is to hide the changes being made to the listitems
' and also to speed up the sort
' Check the data type of the column being sorted,
' and act accordingly
Dim l As Long
Dim strFormat As String
Dim strData() As String
Dim lngIndex As Long
lngIndex = ColumnHeader.Index - 1
Select Case UCase$(ColumnHeader.Tag)
Case "DATE"
' Sort by date.
strFormat = "YYYYMMDDHhNnSs"
' Loop through the values in this column. Re-format
' the dates so as they can be sorted alphabetically,
' having already stored their visible values in the
' tag, along with the tag's original value
With .ListItems
If (lngIndex > 0) Then
For l = 1 To .Count
With .Item(l).ListSubItems(lngIndex)
.Tag = .Text & Chr$(0) & .Tag
If IsDate(.Text) Then
.Text = Format(CDate(.Text), _
strFormat)
Else
.Text = ""
End If
End With
Next l
Else
For l = 1 To .Count
With .Item(l)
.Tag = .Text & Chr$(0) & .Tag
If IsDate(.Text) Then
.Text = Format(CDate(.Text), _
strFormat)
Else
.Text = ""
End If
End With
Next l
End If
End With
' Sort the list alphabetically by this column
.SortOrder = (.SortOrder + 1) Mod 2
.SortKey = ColumnHeader.Index - 1
.Sorted = True
' Restore the previous values to the 'cells' in this
' column of the list from the tags, and also restore
' the tags to their original values
With .ListItems
If (lngIndex > 0) Then
For l = 1 To .Count
With .Item(l).ListSubItems(lngIndex)
strData = Split(.Tag, Chr$(0))
.Text = strData(0)
.Tag = strData(1)
End With
Next l
Else
For l = 1 To .Count
With .Item(l)
strData = Split(.Tag, Chr$(0))
.Text = strData(0)
.Tag = strData(1)
End With
Next l
End If
End With
Case "NUMBER"
' Sort Numerically
strFormat = String(30, "0") & "." & String(30, "0")
' Loop through the values in this column. Re-format the values so as they
' can be sorted alphabetically, having already stored their visible
' values in the tag, along with the tag's original value
With .ListItems
If (lngIndex > 0) Then
For l = 1 To .Count
With .Item(l).ListSubItems(lngIndex)
.Tag = .Text & Chr$(0) & .Tag
If IsNumeric(.Text) Then
If CDbl(.Text) >= 0 Then
.Text = Format(CDbl(.Text), _
strFormat)
Else
.Text = "&" & InvNumber( _
Format(0 - CDbl(.Text), _
strFormat))
End If
Else
.Text = ""
End If
End With
Next l
Else
For l = 1 To .Count
With .Item(l)
.Tag = .Text & Chr$(0) & .Tag
If IsNumeric(.Text) Then
If CDbl(.Text) >= 0 Then
.Text = Format(CDbl(.Text), _
strFormat)
Else
.Text = "&" & InvNumber( _
Format(0 - CDbl(.Text), _
strFormat))
End If
Else
.Text = ""
End If
End With
Next l
End If
End With
' Sort the list alphabetically by this column
.SortOrder = (.SortOrder + 1) Mod 2
.SortKey = ColumnHeader.Index - 1
.Sorted = True
' Restore the previous values to the 'cells' in this
' column of the list from the tags, and also restore
' the tags to their original values
With .ListItems
If (lngIndex > 0) Then
For l = 1 To .Count
With .Item(l).ListSubItems(lngIndex)
strData = Split(.Tag, Chr$(0))
.Text = strData(0)
.Tag = strData(1)
End With
Next l
Else
For l = 1 To .Count
With .Item(l)
strData = Split(.Tag, Chr$(0))
.Text = strData(0)
.Tag = strData(1)
End With
Next l
End If
End With
Case Else ' Assume sort by string
' Sort alphabetically. This is the only sort provided
' by the MS ListView control (at this time), and as
' such we don't really need to do much here
.SortOrder = (.SortOrder + 1) Mod 2
.SortKey = ColumnHeader.Index - 1
.Sorted = True
End Select
.MousePointer = lngCursor
End With
Image28.Enabled = False
Image22.Enabled = True
End Sub
Private Sub lslista_DblClick()
Dim linha, Index
Dim i As Integer
Dim indiceRegistro As Long
Dim oList As Object
Dim j
On Error Resume Next
Set oList = lslista.SelectedItem
If oList Is Nothing Then
Exit Sub
End If
indiceRegistro = UserForm19.ProcuraIndiceRegistroPodId(lslista.ListItems.Item(lslista.SelectedItem.Index))
If indiceRegistro <> -1 Then
Call UserForm19.CarregaRegistroPorIndice(indiceRegistro)
End If
If TextBox34.Text = "1" Then
Image59.Enabled = False
Image30.Enabled = False
Image28.Enabled = True
Image22.Enabled = False
Image29.Visible = False
Image28.Visible = True
Image25.Visible = True
Else
Image59.Enabled = True
Image30.Enabled = False
Image28.Enabled = True
Image22.Enabled = False
Image29.Visible = False
Image28.Visible = True
Image25.Visible = True
End If
End Sub
Private Sub LimpaControles()
Me.txtCodigo.Text = ""
Me.txtproduto.Text = ""
Me.txtunidade.Text = ""
Me.txtvalorp.Text = ""
Me.TextBox1.Text = ""
Me.TextBox32.Text = ""
Me.TextBox4.Text = ""
Me.TextBox6.Text = ""
Me.TextBox35.Text = ""
Me.TextBox36.Text = ""
End Sub
Private Sub HabilitaControles()
Me.txtproduto.Locked = False
Me.TextBox4.Locked = False
Me.TextBox35.Locked = False
Me.TextBox36.Locked = False
'altera a cor dos controles
Me.txtproduto.BackColor = corHabilitaTextBox
Me.TextBox35.BackColor = corHabilitaTextBox
Me.TextBox36.BackColor = corHabilitaTextBox
Me.TextBox4.BackColor = corHabilitaTextBox
Me.TextBox6.BackColor = corHabilitaTextBox
End Sub
Private Sub DesabilitaControles()
Me.txtproduto.Locked = True
Me.txtunidade.Locked = True
Me.txtvalorp.Locked = True
Me.TextBox1.Locked = True
Me.TextBox4.Locked = True
Me.TextBox35.Locked = True
Me.TextBox36.Locked = True
'altera a cor dos controles
Me.txtproduto.BackColor = corDesabilitaTextBox
Me.TextBox1.BackColor = corDesabilitaTextBox
Me.txtvalorp.BackColor = corDesabilitaTextBox
Me.txtunidade.BackColor = corDesabilitaTextBox
Me.TextBox4.BackColor = corDesabilitaTextBox
Me.TextBox6.BackColor = corDesabilitaTextBox
Me.TextBox35.BackColor = corDesabilitaTextBox
Me.TextBox36.BackColor = corDesabilitaTextBox
End Sub
Private Sub HabilitaBotoesAlteracao()
'habilita os botões de alteração
Image28.Enabled = False
Image22.Enabled = False
Image30.Enabled = True
Image23.Enabled = False
Image24.Enabled = False
End Sub
Private Sub DesabilitaBotoesAlteracao()
'desabilita os botões de alteração
Image28.Enabled = False
Image22.Enabled = True
Image26.Visible = False
Image27.Visible = False
Image29.Visible = True
Image31.Visible = True
Image66.Visible = True
Image30.Enabled = False
Image24.Enabled = True
Image23.Enabled = True
End Sub
Private Function ValidaCamposFormulario() As Boolean
If Me.txtproduto.Value = "" Then
MsgBox " 'Matrícula' é um campo obrigatório. ", vbOKOnly, " Campo Obrigatório "
Me.txtproduto.SetFocus
ValidaCamposFormulario = False
Exit Function
ElseIf Me.txtunidade.Value = "" Then
MsgBox "'Setor' é um campo obrigatório. ", vbOKOnly, " Campo Obrigatório "
Me.txtunidade.SetFocus
ValidaCamposFormulario = False
Exit Function
ElseIf Me.txtvalorp.Value = "" Then
MsgBox " 'Cargo' é um campo obrigatório. ", vbOKOnly, " Campo Obrigatório "
Me.txtvalorp.SetFocus
ValidaCamposFormulario = False
Exit Function
ElseIf Me.ComboBox3.Value = "" Then
MsgBox "'Status' é um campo obrigatório. ", vbOKOnly, " Campo Obrigatório "
Me.ComboBox3.SetFocus
ValidaCamposFormulario = False
Exit Function
End If
ValidaCamposFormulario = True
End Function
Private Sub PreencherCabeçalhoLinhas()
Dim Ws As Worksheet
Dim coluna As Integer
Dim linha As Integer
Dim itm As ListItem, n As Long, lngCol As Long
Dim vardata As Variant
Call atualizar
Set Ws = ThisWorkbook.Worksheets(NomeDaPlanilha)
coluna = 1
linha = LinhaCabecalho
Me.lslista.ListItems.Clear
Me.lslista.ColumnHeaders.Clear
vardata = Ws.Range("b1").CurrentRegion.Value
With Ws
While .Cells(linha, coluna).Value <> Empty
With lslista
.View = lvwReport
.Gridlines = True
.ColumnHeaders.Add Text:=Ws.Cells(linha, coluna), Width:=Ws.Cells(linha, coluna).Width
End With
coluna = coluna + 1
Wend
'Preenche as Linhas
With lslista
For n = 2 To UBound(vardata)
Set itm = .ListItems.Add(n - 1, , vardata(n, 1))
For lngCol = 2 To UBound(vardata, 2)
'verifica se é Data e formata a Coluna
If IsDate(vardata(n, lngCol)) Then
itm.ListSubItems.Add , , vardata(n, lngCol)
' itm.ListSubItems.Add , , Format(vardata(n, lngCol), "R$ #,##0.00")
Else
itm.ListSubItems.Add , , vardata(n, lngCol)
End If
Next lngCol
Next n
End With
End With
End Sub
End Sub