You are on page 1of 47

Public TotalPersonal As Integer

Dim IndiceCeldaCodigo(100000) As Long

Dim IndiceCeldaExcel(100000) As Long

'autocom

Private Const r As String = "T2:T500"

Private sInput As String

Dim flParar As Boolean

'fin auto

Public Function RenglonExcel(codigo As Variant) As Long

Longitud = Len(codigo)

If Not IsNumeric(Right(codigo, 5)) Then

If Len(codigo) > 5 Then

Inicio = Longitud - 5

Else

Inicio = 1

End If

EnValor = 0

For Letra = Inicio To Longitud

EnValor = EnValor + Asc(Mid(codigo, Letra, 1))

Next

Else

EnValor = Abs(val(Right(codigo, 5)))

End If

If IndiceCeldaCodigo(EnValor) > 0 Then

If "C" & Worksheets(“Familia”).Cells(IndiceCeldaCodigo(EnValor), 1) = "C" & codigo Then

RenglonExcel = IndiceCeldaCodigo(EnValor)
Exit Function

End If

Else

RenglonExcel = 0

Exit Function

End If

RenglonActual = IndiceCeldaCodigo(EnValor)

For CONTADOR = 1 To 100000

If IndiceCeldaExcel(RenglonActual) > 0 Then

If "C" & Worksheets(“Familia”).Cells(IndiceCeldaExcel(RenglonActual), 1) = "C" & codigo


Then

RenglonExcel = IndiceCeldaExcel(RenglonActual)

Exit Function

End If

RenglonActual = IndiceCeldaExcel(RenglonActual)

Else

RenglonExcel = 0

Exit Function

End If

Next

End Function

'aquiiiii

Public Sub ActualizarIndice()

For CONTADOR = 1 To 100000

IndiceCeldaCodigo(CONTADOR) = 0

Next

For CONTADOR = 2 To 100000

If Worksheets(“Familia”).Cells(CONTADOR, 1) = "" Then

Exit For
Else

If Not IsNumeric(Right(Worksheets(“Familia”).Cells(CONTADOR, 1), 5)) Then

Longitud = Len(Worksheets(“Familia”).Cells(CONTADOR, 1))

If Len(Worksheets(“Familia”).Cells(CONTADOR, 1)) > 5 Then

Inicio = Longitud - 5

Else

Inicio = 1

End If

EnValor = 0

For Letra = Inicio To Longitud

EnValor = EnValor + Asc(Mid(Worksheets(“Familia”).Cells(CONTADOR, 1), Letra, 1))

Next

Else

EnValor = Abs(val(Right(Worksheets(“Familia”).Cells(CONTADOR, 1), 5)))

End If

If IndiceCeldaCodigo(EnValor) = 0 Then

IndiceCeldaExcel(CONTADOR) = 0

IndiceCeldaCodigo(EnValor) = CONTADOR

Else

IndiceCeldaExcel(CONTADOR) = IndiceCeldaCodigo(EnValor)

IndiceCeldaCodigo(EnValor) = CONTADOR

End If

End If

Next

End Sub
'ORDENAR POR ANTIGUEDAD

Public Sub ordenar()

Set mySh = ActiveWorkbook.Worksheets(“Familia”)

With mySh.Sort

.SortFields.Clear

.SortFields.Add Key:=mySh.[E1], SortOn:=xlSortOnValues, _

Order:=xlAscending, DataOption:=xlSortNormal

.SortFields.Add Key:=mySh.[F1], SortOn:=xlSortOnValues, _

Order:=xlAscending, DataOption:=xlSortNormal

.SortFields.Add Key:=mySh.[R1], SortOn:=xlSortOnValues, _

Order:=xlAscending, DataOption:=xlSortNormal

.SortFields.Add Key:=mySh.[S1], SortOn:=xlSortOnValues, _

Order:=xlAscending, DataOption:=xlSortTextAsNumbers

.SetRange mySh.[A1].CurrentRegion: .Header = xlYes

.MatchCase = False: .Orientation = xlTopToBottom

.SortMethod = xlPinYin: .Apply

End With

Set mySh = Nothing

End Sub

'DEVUELVE EL GRALFA SEGUN EL GRADO E INSTITUTO

Sub BuscarGrado()

Dim cont As Long

Dim ultLinea As Long

Dim sueldo As Variant

Dim codigo As Variant

Dim rango As Variant


ultLinea = Sheets(“Familia”).Range("A" & Rows.Count).End(xlUp).Row

Set rango = Sheets("Catalogos").Range("A20:B48")

For cont = 2 To ultLinea

codigo = Sheets(“Familia”).Cells(cont, 4)

sueldo = Application.VLookup(codigo, rango, 2, False)

If IsError(sueldo) Then

sueldo = 0

End If

Sheets(“Familia”).Cells(cont, 6) = sueldo

Next cont

End Sub

Sub BuscarInst()

Dim cont As Long

Dim ultLinea As Long

Dim sueldo As Variant

Dim codigo As Variant

Dim rango As Variant

ultLinea = Sheets(“Familia”).Range("A" & Rows.Count).End(xlUp).Row

Set rango = Sheets("Catalogos").Range("E2:F4")

For cont = 2 To ultLinea

codigo = Sheets(“Familia”).Cells(cont, 9)

sueldo = Application.VLookup(codigo, rango, 2, False)

If IsError(sueldo) Then

sueldo = 0
End If

Sheets(“Familia”).Cells(cont, 19) = sueldo

Next cont

End Sub

'DEVUELVE LA LISTA CON LOS GRADOS SEGUN SU PLANA E INSTITUTO

Private Sub ComboBoxArma_Change()

Select Case Me.ComboBoxArma

Case "Ejercito del Perú"

Select Case Me.ComboBoxPla

Case "Oficial"

Me.ComboBoxGra.RowSource = "Ejercito"

Case "TT.SS.OO"

Me.ComboBoxGra.RowSource = "EjercitoSub"

End Select

Case "Armada del Perú"

Select Case Me.ComboBoxPla

Case "Oficial"

Me.ComboBoxGra.RowSource = "Marina"

Case "TT.SS.OO"

Me.ComboBoxGra.RowSource = "MarinaSub"

End Select

Case "Fuerza Aérea del Perú"

Select Case Me.ComboBoxPla

Case "Oficial"

Me.ComboBoxGra.RowSource = "Fap"

Case "TT.SS.OO"
Me.ComboBoxGra.RowSource = "FapSub"

End Select

End Select

End Sub

Private Sub ComboBoxPla_Change()

'Me.ComboBoxGra = ""

Select Case Me.ComboBoxPla

Case "Oficial"

Select Case Me.ComboBoxArma

Case "Ejercito del Perú"

Me.ComboBoxGra.RowSource = "Ejercito"

Case "Armada del Perú"

Me.ComboBoxGra.RowSource = "Marina"

Case "Fuerza Aérea del Perú"

Me.ComboBoxGra.RowSource = "Fap"

End Select

Case "TT.SS.OO"

Select Case Me.ComboBoxArma

Case "Ejercito del Perú"

Me.ComboBoxGra.RowSource = "EjercitoSub"

Case "Armada del Perú"

Me.ComboBoxGra.RowSource = "MarinaSub"

Case "Fuerza Aérea del Perú"

Me.ComboBoxGra.RowSource = "FapSub"

End Select
End Select

End Sub

'FUNCIONALIDAD DEL BOTON ANTERIOR

Private Sub CommandButtonAnterior_Click()

If LabelNuevo <> "NUEVO REGISTRO" Then

If ConvertiraNumero(TextBoxId) > 2 Then

If Worksheets(“Familia”).Cells(TextBoxId - 1, 1) <> "" Then

TextBoxId = TextBoxId - 1

CONTADOR = TextBoxId

AñadirALista = True

If AñadirALista Then

ActualizarFoto (Worksheets(“Familia”).Cells(CONTADOR, 2))

LabelCodigo = Trim(Worksheets(“Familia”).Cells(CONTADOR, 2))

TextBoxA = Worksheets(“Familia”).Cells(CONTADOR, 1) 'DNI

TextBoxB = Trim(Worksheets(“Familia”).Cells(CONTADOR, 2)) 'APELLIDOS

TextBoxC = Trim(Worksheets(“Familia”).Cells(CONTADOR, 3)) 'NSA

ComboBoxGra = Trim(Worksheets(“Familia”).Cells(CONTADOR, 4)) 'GRADO

ComboBoxPla = Trim(Worksheets(“Familia”).Cells(CONTADOR, 5)) 'PLANA

TextBoxF = Trim(Worksheets(“Familia”).Cells(CONTADOR, 6)) 'NUESCA

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 7)) Then

TextBoxG.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxG = Trim(Worksheets(“Familia”).Cells(CONTADOR, 7)) ''FENACI

End If
ComboBoxEstC = Trim(Worksheets(“Familia”).Cells(CONTADOR, 8)) 'ESTCIVIL

ComboBoxArma = Trim(Worksheets(“Familia”).Cells(CONTADOR, 9)) 'INSTITUTO

TextBoxJ = Format(Trim(Worksheets(“Familia”).Cells(CONTADOR, 10)), "general


number") 'peso

TextBoxK = Format(Trim(Worksheets(“Familia”).Cells(CONTADOR, 11)),


"Standard") 'talla

TextBoxL = Trim(Worksheets(“Familia”).Cells(CONTADOR, 12)) 'CTA

TextBoxM = Trim(Worksheets(“Familia”).Cells(CONTADOR, 13)) 'BREVETE

ComboBoxInst = Trim(Worksheets(“Familia”).Cells(CONTADOR, 14)) 'GRADO INT

ComboBoxSN = Trim(Worksheets(“Familia”).Cells(CONTADOR, 15)) 'VEHICULO

ComboBoxSan = Trim(Worksheets(“Familia”).Cells(CONTADOR, 16)) 'GRUSAN

TextBoxQ = Trim(Worksheets(“Familia”).Cells(CONTADOR, 17)) 'CCI

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 18)) Then

TextBoxR.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxR = Trim(Worksheets(“Familia”).Cells(CONTADOR, 18)) 'FEULAS

End If

TextBoxEspe = Trim(Worksheets(“Familia”).Cells(CONTADOR, 20)) 'ESPECIALIDAD

TextBoxDep = Trim(Worksheets(“Familia”).Cells(CONTADOR, 21))


'DEPARTAMENTO

TextBoxProv = Trim(Worksheets(“Familia”).Cells(CONTADOR, 22)) 'PROVINCIA

TextBoxDis = Trim(Worksheets(“Familia”).Cells(CONTADOR, 23)) 'DISTRITO

TextBoxTel = Trim(Worksheets(“Familia”).Cells(CONTADOR, 24)) 'TELEFONO

TextBoxCel1 = Trim(Worksheets(“Familia”).Cells(CONTADOR, 25)) 'CELULAR1

TextBoxCel2 = Trim(Worksheets(“Familia”).Cells(CONTADOR, 26)) 'CELULAR2

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 27)) Then

TextBoxFein.value = Format(Date, "dd/mm/yyyy")

' TextBoxFein.CalendarBackColor = vbGreen

Else
TextBoxFein = Trim(Worksheets(“Familia”).Cells(CONTADOR, 27)) 'FEULAS

End If

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 28)) Then

TextBoxInmin.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxInmin = Trim(Worksheets(“Familia”).Cells(CONTADOR, 28)) 'FEULAS

End If

TextBoxDir = Trim(Worksheets(“Familia”).Cells(CONTADOR, 29)) 'DIRECCION

TextBoxDisd = Trim(Worksheets(“Familia”).Cells(CONTADOR, 30)) 'DISTRITO


DONDE VIVE

TextBoxCondi = Trim(Worksheets(“Familia”).Cells(CONTADOR, 31)) 'CONDICION DE


ALTA

End If 'If AñadirALista Then

End If

End If

End If

End Sub

Private Sub CommandButtonAnterior_MouseMove(ByVal Button As Integer, ByVal Shift As


Integer, ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Anterior Registro"

End Sub

Private Sub CommandButtonBuscar_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Busqueda por Palabra"

End Sub
Private Sub CommandButtonBuscarPorCodigo_Click()

End Sub

Private Sub ActualizarInventario_Click()

End Sub

Private Sub ActualizarInventario_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Te permite actualizar tu inventario, es recomendable cuando se


hacen modificaciones directamente en Tabla Personal"

End Sub

Private Sub CommandButtonActualizar_MouseMove(ByVal Button As Integer, ByVal Shift As


Integer, ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Te permite guardar todas tus modificaciones, codigo de confirmacion


123"

End Sub

Private Sub CommandButtonBuscarPorCodigo_Enter()

If LabelNuevo = "NUEVO REGISTRO" Then

MsgBox "Los cambios no se guardaron"

End If

ActualizarFoto ("")

LabelNuevo = ""
TextBoxA = ""

TextBoxB = ""

TextBoxC = ""

ComboBoxGra = ""

ComboBoxPla = ""

TextBoxF = ""

TextBoxG = Format(Date, "dd/mm/yyyy")

ComboBoxEstC = ""

ComboBoxArma = ""

TextBoxJ = ""

TextBoxK = ""

TextBoxL = ""

TextBoxM = ""

ComboBoxInst = ""

ComboBoxSN = ""

ComboBoxSan = ""

TextBoxQ = ""

TextBoxR = Format(Date, "dd/mm/yyyy")

TextBoxEspe = ""

TextBoxDep = ""

TextBoxProv = ""

TextBoxDis = ""

TextBoxTel = ""

TextBoxCel1 = ""

TextBoxCel2 = ""

TextBoxFein = Format(Date, "dd/mm/yyyy")

TextBoxInmin = Format(Date, "dd/mm/yyyy")

TextBoxDir = ""

TextBoxDisd = ""
TextBoxCondi = ""

BuscarCodigo.Text = Trim(VBA.Replace(BuscarCodigo.Text, VBA.Chr(9), ""))

Dim IndiceCodigo As Long

If Len(Trim(BuscarCodigo.value)) > 0 Then

ListaPersonal.Clear

Dim AñadirALista As Boolean

EsPrimeraFila = True

If RenglonExcel(BuscarCodigo) > 0 Then

CONTADOR = RenglonExcel(BuscarCodigo)

TextBoxId = RenglonExcel(BuscarCodigo)

AñadirALista = True

If Not InStr(1, NoAcentos(Worksheets(“Familia”).Cells(CONTADOR, 1)),


Trim(NoAcentos(BuscarCodigo.value)), vbTextCompare) > 0 Then

AñadirALista = False

End If

End If

If AñadirALista Then

'BUSCA CON ENTER

ActualizarFoto (Worksheets(“Familia”).Cells(CONTADOR, 2))

LabelCodigo = Trim(Worksheets(“Familia”).Cells(CONTADOR, 2))

TextBoxA = Worksheets(“Familia”).Cells(CONTADOR, 1) 'DNI

TextBoxB = Trim(Worksheets(“Familia”).Cells(CONTADOR, 2)) 'APELLIDOS


TextBoxC = Trim(Worksheets(“Familia”).Cells(CONTADOR, 3)) 'NSA

ComboBoxGra = Trim(Worksheets(“Familia”).Cells(CONTADOR, 4)) 'GRADO

ComboBoxPla = Trim(Worksheets(“Familia”).Cells(CONTADOR, 5)) 'PLANA

TextBoxF = Trim(Worksheets(“Familia”).Cells(CONTADOR, 6)) 'NUESCA

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 7)) Then

TextBoxG.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxG = Trim(Worksheets(“Familia”).Cells(CONTADOR, 7)) ''FENACI

End If

ComboBoxEstC = Trim(Worksheets(“Familia”).Cells(CONTADOR, 8)) 'ESTCIVIL

ComboBoxArma = Trim(Worksheets(“Familia”).Cells(CONTADOR, 9)) 'INSTITUTO

TextBoxJ = Format(Trim(Worksheets(“Familia”).Cells(CONTADOR, 10)), "general


number") 'peso

TextBoxK = Format(Trim(Worksheets(“Familia”).Cells(CONTADOR, 11)),


"Standard") 'talla

TextBoxL = Trim(Worksheets(“Familia”).Cells(CONTADOR, 12)) 'CTA

TextBoxM = Trim(Worksheets(“Familia”).Cells(CONTADOR, 13)) 'BREVETE

ComboBoxInst = Trim(Worksheets(“Familia”).Cells(CONTADOR, 14)) 'GRADO INT

ComboBoxSN = Trim(Worksheets(“Familia”).Cells(CONTADOR, 15)) 'VEHICULO

ComboBoxSan = Trim(Worksheets(“Familia”).Cells(CONTADOR, 16)) 'GRUSAN

TextBoxQ = Trim(Worksheets(“Familia”).Cells(CONTADOR, 17)) 'CCI

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 18)) Then

TextBoxR.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxR = Trim(Worksheets(“Familia”).Cells(CONTADOR, 18)) 'FEULAS

End If

TextBoxEspe = Trim(Worksheets(“Familia”).Cells(CONTADOR, 20)) 'ESPECIALIDAD

TextBoxDep = Trim(Worksheets(“Familia”).Cells(CONTADOR, 21))


'DEPARTAMENTO

TextBoxProv = Trim(Worksheets(“Familia”).Cells(CONTADOR, 22)) 'PROVINCIA


TextBoxDis = Trim(Worksheets(“Familia”).Cells(CONTADOR, 23)) 'DISTRITO

TextBoxTel = Trim(Worksheets(“Familia”).Cells(CONTADOR, 24)) 'TELEFONO

TextBoxCel1 = Trim(Worksheets(“Familia”).Cells(CONTADOR, 25)) 'CELULAR1

TextBoxCel2 = Trim(Worksheets(“Familia”).Cells(CONTADOR, 26)) 'CELULAR2

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 27)) Then

TextBoxFein.value = Format(Date, "dd/mm/yyyy")

' TextBoxFein.CalendarBackColor = vbGreen

Else

TextBoxFein = Trim(Worksheets(“Familia”).Cells(CONTADOR, 27)) 'FEULAS

End If

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 28)) Then

TextBoxInmin.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxInmin = Trim(Worksheets(“Familia”).Cells(CONTADOR, 28)) 'FEULAS

End If 'FEC. INGRESO MINDEF

TextBoxDir = Trim(Worksheets(“Familia”).Cells(CONTADOR, 29)) 'DIRECCION

TextBoxDisd = Trim(Worksheets(“Familia”).Cells(CONTADOR, 30)) 'DISTRITO


DONDE VIVE

TextBoxCondi = Trim(Worksheets(“Familia”).Cells(CONTADOR, 31)) 'CONDICION DE


ALTA

ListaPersonal.AddItem ""

ListaPersonal.List(ListaPersonal.ListCount - 1, 0) =
Worksheets(“Familia”).Cells(CONTADOR, 1)

ListaPersonal.List(ListaPersonal.ListCount - 1, 1) =
Worksheets(“Familia”).Cells(CONTADOR, 2)

ListaPersonal.List(ListaPersonal.ListCount - 1, 2) =
Worksheets(“Familia”).Cells(CONTADOR, 3)
ListaPersonal.List(ListaPersonal.ListCount - 1, 3) =
Worksheets(“Familia”).Cells(CONTADOR, 4)

ListaPersonal.List(ListaPersonal.ListCount - 1, 4) =
Worksheets(“Familia”).Cells(CONTADOR, 5)

ListaPersonal.List(ListaPersonal.ListCount - 1, 5) =
Worksheets(“Familia”).Cells(CONTADOR, 7)

ListaPersonal.List(ListaPersonal.ListCount - 1, 6) =
Worksheets(“Familia”).Cells(CONTADOR, 9)

ListaPersonal.List(ListaPersonal.ListCount - 1, 7) =
Worksheets(“Familia”).Cells(CONTADOR, 10)

ListaPersonal.List(ListaPersonal.ListCount - 1, 8) =
Format(Trim(Worksheets(“Familia”).Cells(CONTADOR, 11)), "0,00")

ListaPersonal.List(ListaPersonal.ListCount - 1, 9) = TextBoxId

BuscarCodigo.value = ""

End If 'If AñadirALista Then

End If 'If Len(Trim(TextBoxCodigo.Value)) > 0 And TextBoxCodigo <> "+" Then

BuscarCodigo.SetFocus

End Sub

Private Sub CommandButtonBuscarPorCodigo_MouseMove(ByVal Button As Integer, ByVal Shift


As Integer, ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Busqueda por Codigo"

End Sub

Private Sub CommandButtonMisImagenes_MouseMove(ByVal Button As Integer, ByVal Shift As


Integer, ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Te permite visualizar todas tus imagenes de la carpeta


TOOLS\IMAGES"
End Sub

Private Sub CommandButtonQR_Click()

If Trim(TextBoxA) = "" Then

MsgBox "Seleccione un articulo para generar codigo QR"

Else

CrearCodigoQR = CodigoQR("CodigoQR", TextBoxA & TextBoxB & TextBoxC, RenglonQR + 4,


75, 265)

End If

End Sub

Private Sub CommandButtonQR_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Te permite generar un Codigo QR, el archivo JPG se encuentra en la


carpeta de tus imagenes"

End Sub

'SE CARGA PRIMERO

Private Sub CommandButtonSiguiente_Click()

If LabelNuevo <> "NUEVO REGISTRO" Then

If ConvertiraNumero(TextBoxId) = 0 Then

TextBoxId = 1

End If

If ConvertiraNumero(TextBoxId) > 0 Then

If Worksheets(“Familia”).Cells(TextBoxId + 1, 1) <> "" Then

TextBoxId = TextBoxId + 1

CONTADOR = TextBoxId

AñadirALista = True
If AñadirALista Then

ActualizarFoto (Worksheets(“Familia”).Cells(CONTADOR, 2))

LabelCodigo = Trim(Worksheets(“Familia”).Cells(CONTADOR, 2))

TextBoxA = Worksheets(“Familia”).Cells(CONTADOR, 1) 'DNI

TextBoxB = Trim(Worksheets(“Familia”).Cells(CONTADOR, 2)) 'APELLIDOS

TextBoxC = Trim(Worksheets(“Familia”).Cells(CONTADOR, 3)) 'NSA

ComboBoxGra = Trim(Worksheets(“Familia”).Cells(CONTADOR, 4)) 'GRADO

ComboBoxPla = Trim(Worksheets(“Familia”).Cells(CONTADOR, 5)) 'PLANA

TextBoxF = Trim(Worksheets(“Familia”).Cells(CONTADOR, 6)) 'NUESCA

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 7)) Then

TextBoxG.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxG = Trim(Worksheets(“Familia”).Cells(CONTADOR, 7)) ''FENACI

End If

ComboBoxEstC = Trim(Worksheets(“Familia”).Cells(CONTADOR, 8)) 'ESTCIVIL

ComboBoxArma = Trim(Worksheets(“Familia”).Cells(CONTADOR, 9)) 'INSTITUTO

TextBoxJ = Format(Trim(Worksheets(“Familia”).Cells(CONTADOR, 10)), "general


number") 'peso

TextBoxK = Format(Trim(Worksheets(“Familia”).Cells(CONTADOR, 11)),


"Standard") 'talla

TextBoxL = Trim(Worksheets(“Familia”).Cells(CONTADOR, 12)) 'CTA

TextBoxM = Trim(Worksheets(“Familia”).Cells(CONTADOR, 13)) 'BREVETE

ComboBoxInst = Trim(Worksheets(“Familia”).Cells(CONTADOR, 14)) 'GRADO INT

ComboBoxSN = Trim(Worksheets(“Familia”).Cells(CONTADOR, 15)) 'VEHICULO

ComboBoxSan = Trim(Worksheets(“Familia”).Cells(CONTADOR, 16)) 'GRUSAN

TextBoxQ = Trim(Worksheets(“Familia”).Cells(CONTADOR, 17)) 'CCI


If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 18)) Then

TextBoxR.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxR = Trim(Worksheets(“Familia”).Cells(CONTADOR, 18)) 'FEULAS

End If

TextBoxEspe = Trim(Worksheets(“Familia”).Cells(CONTADOR, 20)) 'ESPECIALIDAD

TextBoxDep = Trim(Worksheets(“Familia”).Cells(CONTADOR, 21))


'DEPARTAMENTO

TextBoxProv = Trim(Worksheets(“Familia”).Cells(CONTADOR, 22)) 'PROVINCIA

TextBoxDis = Trim(Worksheets(“Familia”).Cells(CONTADOR, 23)) 'DISTRITO

TextBoxTel = Trim(Worksheets(“Familia”).Cells(CONTADOR, 24)) 'TELEFONO

TextBoxCel1 = Trim(Worksheets(“Familia”).Cells(CONTADOR, 25)) 'CELULAR1

TextBoxCel2 = Trim(Worksheets(“Familia”).Cells(CONTADOR, 26)) 'CELULAR2

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 27)) Then

TextBoxFein.value = Format(Date, "dd/mm/yyyy")

' TextBoxFein.CalendarBackColor = vbGreen

Else

TextBoxFein = Trim(Worksheets(“Familia”).Cells(CONTADOR, 27)) 'FEULAS

End If

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 28)) Then

TextBoxInmin.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxInmin = Trim(Worksheets(“Familia”).Cells(CONTADOR, 28)) 'FEULAS

End If

'TextBoxFein = Format(Worksheets(“Familia”).Cells(CONTADOR, 27),


"dd/mm/yyyy") 'FECHA DE INGRESO INSTITUTO

'TextBoxInmin = Format(Worksheets(“Familia”).Cells(CONTADOR, 28),


"dd/mm/yyyy") 'FEC. INGRESO MINDEF
TextBoxDir = Trim(Worksheets(“Familia”).Cells(CONTADOR, 29)) 'DIRECCION

TextBoxDisd = Trim(Worksheets(“Familia”).Cells(CONTADOR, 30)) 'DISTRITO


DONDE VIVE

TextBoxCondi = Trim(Worksheets(“Familia”).Cells(CONTADOR, 31)) 'CONDICION DE


ALTA

'ComboBoxPla = Trim(Worksheets(“Familia”).Cells(CONTADOR, 5))

'TextBoxK =
Format(ConvertiraNumero(Trim(Worksheets(“Familia”).Cells(CONTADOR, 11) * 100)), "GENERAL
NUMBER")

End If 'If AñadirALista Then

End If

End If

End If

End Sub

Private Sub CommandButtonSiguiente_MouseMove(ByVal Button As Integer, ByVal Shift As


Integer, ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Siguiente Registro"

End Sub

Private Sub ImagenPrincipal_Click()

End Sub

Private Sub ListaPersonal_Exit(ByVal Cancel As MSForms.ReturnBoolean)

ListaPersonal.Visible = False
BuscarCodigo.SetFocus

End Sub

'End Sub

Private Sub TextBoxA_Exit(ByVal Cancel As MSForms.ReturnBoolean)

'MsgBox RenglonExcel(TextBoxA)

If RenglonExcel(TextBoxA) > 0 Then

MsgBox "Este codigo ya se encuentra registrado"

End If

End Sub

Private Sub TextBoxB_Change()

LabelCodigo = TextBoxB

End Sub

Private Sub TextBoxC_Change()

If TextBoxC = "." Then

TextBoxC = "0."

End If

If Not IsNumeric(TextBoxC) Then

TextBoxC = ""

End If

End Sub

'autocompletar

Private Sub TextBoxEspe_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As


Integer)
If (KeyCode = vbKeyBack) Or (KeyCode = vbKeyDelete) Then

flParar = True

Else

flParar = False

End If

If (KeyCode = 13) Then

ActiveCell.value = FormaPersonal.TextBoxEspe.Text

FormaPersonal.TextBoxEspe.value = vbNullString

FormaPersonal.Hide

End If

End Sub

Private Sub TextBoxEspe_Change()

Dim lPalavra As String

If flParar Then

flParar = False

Else

sInput = Left(Me.TextBoxEspe, Me.TextBoxEspe.SelStart)

lPalavra = GetFirstCloserWord(sInput)

If lPalavra & "" <> "" Then

flParar = True

Me.TextBoxEspe.Text = lPalavra

Me.TextBoxEspe.SelStart = Len(sInput)

Me.TextBoxEspe.SelLength = 999999

End If

End If
End Sub

Private Function GetFirstCloserWord(ByVal Word As String) As String

Dim c As Range

For Each c In Sheets(“Familia”).Range(r).Cells

If TextBoxEspe <> "" Then

If LCase(c.value) Like LCase(Word & "*") Then

GetFirstCloserWord = c.value

Exit Function

End If

End If

Next c

Set c = Nothing

End Function

'****fin de autocompletar

Private Sub TextBoxK_Change()

If Not IsNumeric(TextBoxK) Then

TextBoxK = "0.00"

End If

End Sub

'aqui
Private Sub UserForm_Activate()

ActualizarIndice

CommandButtonBuscarPorCodigo.Default = True

For CONTADOR = 2 To 100000

If Worksheets(“Familia”).Cells(CONTADOR, 1) = "" Then

TotalPersonal = CONTADOR - 1

Exit For

End If

Next

CommandButtonSiguiente_Click

BuscarCodigo.SetFocus

End Sub

Private Sub CommandButtonBuscar_Click()

BuscarCodigo.Text = Trim(VBA.Replace(BuscarCodigo.Text, VBA.Chr(9), ""))

If Len(Trim(BuscarCodigo.value)) > 0 Then '***************************


Len(BuscarCodigo.Value)

ReDim Seleccionado(100000) As Boolean

ReDim Palabra(100) As String

Dim EsPrimeraFila, AñadirALista As Boolean

ListaPersonal.Clear

Palabra(1) = ""
ContarPalabra = 1

For ContarLetra = 1 To Len(BuscarCodigo)

If Mid(BuscarCodigo, ContarLetra, 1) = " " Then

If Not Palabra(ContarPalabra) = "" Then

ContarPalabra = ContarPalabra + 1

Palabra(ContarPalabra) = ""

End If

Else

Palabra(ContarPalabra) = Palabra(ContarPalabra) & Mid(BuscarCodigo,


ContarLetra, 1)

End If

Next

EsPrimeraFila = True

For CONTADOR = 2 To TotalPersonal '********** Contador

'If Seleccionado(contador) = False Then

TemporalGlobal = NoAcentos(Worksheets(“Familia”).Cells(CONTADOR, 1) & " " &


Worksheets(“Familia”).Cells(CONTADOR, 2) & " " & Worksheets(“Familia”).Cells(CONTADOR, 5) & "
" & Worksheets(“Familia”).Cells(CONTADOR, 9) & " " & Worksheets(“Familia”).Cells(CONTADOR,
10))

AñadirALista = True

'Seleccionado(contador) = True

For ContarTrues = 1 To ContarPalabra

If Not InStr(1, TemporalGlobal, Trim(NoAcentos(Palabra(ContarTrues))),


vbTextCompare) > 0 Then

AñadirALista = False

'Seleccionado(contador) = False

End If
Next

'End If

If AñadirALista Then

AñadirALista = False

If EsPrimeraFila = True Then

EsPrimeraFila = False

TextBoxId = CONTADOR

ActualizarFoto (Worksheets(“Familia”).Cells(CONTADOR, 2))

LabelCodigo = Trim(Worksheets(“Familia”).Cells(CONTADOR, 2))

TextBoxA = Worksheets(“Familia”).Cells(CONTADOR, 1) 'DNI

TextBoxB = Trim(Worksheets(“Familia”).Cells(CONTADOR, 2)) 'APELLIDOS

TextBoxC = Trim(Worksheets(“Familia”).Cells(CONTADOR, 3)) 'NSA

ComboBoxGra = Trim(Worksheets(“Familia”).Cells(CONTADOR, 4)) 'GRADO

ComboBoxPla = Trim(Worksheets(“Familia”).Cells(CONTADOR, 5)) 'PLANA

TextBoxF = Trim(Worksheets(“Familia”).Cells(CONTADOR, 6)) 'NUESCA

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 7)) Then

TextBoxG.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxG = Trim(Worksheets(“Familia”).Cells(CONTADOR, 7)) ''FENACI

End If

ComboBoxEstC = Trim(Worksheets(“Familia”).Cells(CONTADOR, 8)) 'ESTCIVIL

ComboBoxArma = Trim(Worksheets(“Familia”).Cells(CONTADOR, 9)) 'INSTITUTO


TextBoxJ = Format(Trim(Worksheets(“Familia”).Cells(CONTADOR, 10)), "general
number") 'peso

TextBoxK = Format(Trim(Worksheets(“Familia”).Cells(CONTADOR, 11)),


"Standard") 'talla

TextBoxL = Trim(Worksheets(“Familia”).Cells(CONTADOR, 12)) 'CTA

TextBoxM = Trim(Worksheets(“Familia”).Cells(CONTADOR, 13)) 'BREVETE

ComboBoxInst = Trim(Worksheets(“Familia”).Cells(CONTADOR, 14)) 'GRADO INT

ComboBoxSN = Trim(Worksheets(“Familia”).Cells(CONTADOR, 15)) 'VEHICULO

ComboBoxSan = Trim(Worksheets(“Familia”).Cells(CONTADOR, 16)) 'GRUSAN

TextBoxQ = Trim(Worksheets(“Familia”).Cells(CONTADOR, 17)) 'CCI

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 18)) Then

TextBoxR.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxR = Trim(Worksheets(“Familia”).Cells(CONTADOR, 18)) 'FEULAS

End If

TextBoxEspe = Trim(Worksheets(“Familia”).Cells(CONTADOR, 20)) 'ESPECIALIDAD

TextBoxDep = Trim(Worksheets(“Familia”).Cells(CONTADOR, 21))


'DEPARTAMENTO

TextBoxProv = Trim(Worksheets(“Familia”).Cells(CONTADOR, 22)) 'PROVINCIA

TextBoxDis = Trim(Worksheets(“Familia”).Cells(CONTADOR, 23)) 'DISTRITO

TextBoxTel = Trim(Worksheets(“Familia”).Cells(CONTADOR, 24)) 'TELEFONO

TextBoxCel1 = Trim(Worksheets(“Familia”).Cells(CONTADOR, 25)) 'CELULAR1

TextBoxCel2 = Trim(Worksheets(“Familia”).Cells(CONTADOR, 26)) 'CELULAR2

If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 27)) Then

TextBoxFein.value = Format(Date, "dd/mm/yyyy")

' TextBoxFein.CalendarBackColor = vbGreen

Else

TextBoxFein = Trim(Worksheets(“Familia”).Cells(CONTADOR, 27)) 'FEULAS

End If
If IsEmpty(Worksheets(“Familia”).Cells(CONTADOR, 28)) Then

TextBoxInmin.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxInmin = Trim(Worksheets(“Familia”).Cells(CONTADOR, 28)) 'FEULAS

End If 'FEC. INGRESO MINDEF

TextBoxDir = Trim(Worksheets(“Familia”).Cells(CONTADOR, 29)) 'DIRECCION

TextBoxDisd = Trim(Worksheets(“Familia”).Cells(CONTADOR, 30)) 'DISTRITO


DONDE VIVE

TextBoxCondi = Trim(Worksheets(“Familia”).Cells(CONTADOR, 31)) 'CONDICION DE


ALTA

End If

'arma la lista visible

ListaPersonal.AddItem ""

ListaPersonal.List(ListaPersonal.ListCount - 1, 0) =
Trim(Worksheets(“Familia”).Cells(CONTADOR, 1))

ListaPersonal.List(ListaPersonal.ListCount - 1, 1) =
Trim(Worksheets(“Familia”).Cells(CONTADOR, 2))

ListaPersonal.List(ListaPersonal.ListCount - 1, 2) =
Worksheets(“Familia”).Cells(CONTADOR, 3)

ListaPersonal.List(ListaPersonal.ListCount - 1, 3) =
Worksheets(“Familia”).Cells(CONTADOR, 4)

ListaPersonal.List(ListaPersonal.ListCount - 1, 4) =
Worksheets(“Familia”).Cells(CONTADOR, 5)

'ListaPersonal.List(ListaPersonal.ListCount - 1, 5) =
Worksheets(“Familia”).Cells(Contador, 7)

ListaPersonal.List(ListaPersonal.ListCount - 1, 6) =
Worksheets(“Familia”).Cells(CONTADOR, 9)

ListaPersonal.List(ListaPersonal.ListCount - 1, 7) =
Worksheets(“Familia”).Cells(CONTADOR, 10)
ListaPersonal.List(ListaPersonal.ListCount - 1, 8) =
Worksheets(“Familia”).Cells(CONTADOR, 11)

ListaPersonal.List(ListaPersonal.ListCount - 1, 9) = CONTADOR

End If

Next '************************* Contador 2 to 10000

If ListaPersonal.ListCount > 0 Then

ListaPersonal.Visible = True

ListaPersonal.Selected(0) = True

ListaPersonal.SetFocus

Else

MsgBox "No hay coincidencias"

BuscarCodigo.SetFocus

End If

End If '***************************************** Len(BuscarCodigo.Value)

End Sub

Private Sub BotonImagen_Click()

ClaveImagen = TextBoxC.value

VentanaImagen.Show

End Sub

Private Sub BotonPreferencias_Click()

VentanaPreferencias.Show

End Sub

Private Sub BotonLocalizador_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X


As Single, ByVal Y As Single)
FormaPersonal.Caption = "Este boton te permite guardar todos los cambios. La contraseña de
confirmación es 123. Debes tener un producto seleccionado o nuevo registro."

End Sub

Private Sub BotonTodosPersonal_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Te permite ingresar todos los productos en la lista."

End Sub

Private Sub CommandButton10_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Te permite visualizar la carpeta donde se guardan todas tus imagenes."

End Sub

Private Sub CommandButton13_Click()

End Sub

Private Sub CommandButton13_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Busca información relacionado de la casilla Buscar Producto."

End Sub
Private Sub CommandButton14_Click() 'copia imagen

On Error GoTo SALIR

If TextBoxB <> "" Then

Ruta = ThisWorkbook.Path

NombredeArchivo = Application.GetOpenFilename("JPG Files (*.jpg), *.jpg")

If NombredeArchivo <> False Then

ActualizarFotoPRE (NombredeArchivo)

If Len(Dir(NombredeArchivo)) = 0 Then

MsgBox "This file does NOT exist."

Else

'If TextBoxB <> "" Then

'ClaveUsuario = 0

'ClaveUsuario = InputBox("Contraseña de confirmación para cambiar


imagen")

'If ClaveUsuario = "123" Then

'MsgBox Ruta & "\TOOLS\IMAGES\" & TextBoxB & ".jpg"

'If Dir(nombredearchivo, vbDirectory) = Dir(Ruta & "\Tools\Images\" &


TextBoxB & ".jpg", vbDirectory) Then

' MsgBox "Ya se encuentra archivo"

'Else

FileCopy NombredeArchivo, Ruta & "\Tools\Images\" & TextBoxB &


".jpg"

'MsgBox "Archivo de imagen copiado."


'End If

'MsgBox "Archivo de Imagen Copiado"

'Else

'ActualizarFoto ("")

'End If

'End If

End If

End If

Else

MsgBox "Selecciona primero un articulo"

End If

SALIR:

End Sub

Private Sub CommandButton14_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Te permite elegir o cambiar una imagen para el producto. Codigo de
confirmacion es: 123"

End Sub

Private Sub CommandButtonActualizar_Click()

ClaveUsuario = 0

If IsNumeric(TextBoxId) Then

ClaveUsuario = InputBox("Introduzca Contraseña de Confirmacion")


If ClaveUsuario <> "123" Then

MsgBox "Los cambios no se guardaron", vbCritical

End If

If ClaveUsuario = "123" Then

Worksheets(“Familia”).Cells(TextBoxId, 1).NumberFormat = "@"

Worksheets(“Familia”).Cells(TextBoxId, 1) = TextBoxA.value

Worksheets(“Familia”).Cells(TextBoxId, 1).Errors(xlNumberAsText).Ignore = True

Worksheets(“Familia”).Cells(TextBoxId, 2) = TextBoxB.value

Worksheets(“Familia”).Cells(TextBoxId, 3) = TextBoxC.value

Worksheets(“Familia”).Cells(TextBoxId, 4) = ComboBoxGra.value

Worksheets(“Familia”).Cells(TextBoxId, 5) = ComboBoxPla.value

Worksheets(“Familia”).Cells(TextBoxId, 7) = TextBoxG.value

Worksheets(“Familia”).Cells(TextBoxId, 8) = ComboBoxEstC.value

Worksheets(“Familia”).Cells(TextBoxId, 9) = ComboBoxArma.value

Worksheets(“Familia”).Cells(TextBoxId, 10) = TextBoxJ.value

If TextBoxK.value = "" Then

Worksheets(“Familia”).Cells(TextBoxId, 11) = Format(0, "0,00")

Else

Worksheets(“Familia”).Cells(TextBoxId, 11) = FormatNumber(TextBoxK.value, 2)

End If

Worksheets(“Familia”).Cells(TextBoxId, 12) = TextBoxL.value

Worksheets(“Familia”).Cells(TextBoxId, 13) = TextBoxM.value

Worksheets(“Familia”).Cells(TextBoxId, 14) = ComboBoxInst.value

Worksheets(“Familia”).Cells(TextBoxId, 15) = ComboBoxSN.value

Worksheets(“Familia”).Cells(TextBoxId, 16) = ComboBoxSan.value

Worksheets(“Familia”).Cells(TextBoxId, 17) = TextBoxQ.value

Worksheets(“Familia”).Cells(TextBoxId, 18) = TextBoxR.value

Worksheets(“Familia”).Cells(TextBoxId, 20) = TextBoxEspe.value


Worksheets(“Familia”).Cells(TextBoxId, 21) = TextBoxDep.value

Worksheets(“Familia”).Cells(TextBoxId, 22) = TextBoxProv.value

Worksheets(“Familia”).Cells(TextBoxId, 23) = TextBoxDis.value

Worksheets(“Familia”).Cells(TextBoxId, 24) = TextBoxTel.value

Worksheets(“Familia”).Cells(TextBoxId, 25) = TextBoxCel1.value

Worksheets(“Familia”).Cells(TextBoxId, 26) = TextBoxCel2.value

Worksheets(“Familia”).Cells(TextBoxId, 27) = TextBoxFein.value

Worksheets(“Familia”).Cells(TextBoxId, 28) = TextBoxInmin.value

Worksheets(“Familia”).Cells(TextBoxId, 29) = TextBoxDir.value

Worksheets(“Familia”).Cells(TextBoxId, 30) = TextBoxDisd.value

Worksheets(“Familia”).Cells(TextBoxId, 31) = TextBoxCondi

For Seleccionado = 0 To ListaPersonal.ListCount - 1

If ListaPersonal.List(Seleccionado, 9) = TextBoxId Then

ListaPersonal.List(Seleccionado, 0) = TextBoxA

ListaPersonal.List(Seleccionado, 1) = TextBoxB

ListaPersonal.List(Seleccionado, 2) = TextBoxC

ListaPersonal.List(Seleccionado, 3) = ComboBoxGra

ListaPersonal.List(Seleccionado, 4) = ComboBoxPla

ListaPersonal.List(Seleccionado, 5) = TextBoxG 'H FALTA

ListaPersonal.List(Seleccionado, 6) = ComboBoxArma

ListaPersonal.List(Seleccionado, 7) = TextBoxJ

ListaPersonal.List(Seleccionado, 8) = Format(TextBoxK, "0,00")

ListaPersonal.List(Seleccionado, 10) = TextBoxK

ListaPersonal.List(Seleccionado, 11) = TextBoxL

ListaPersonal.List(Seleccionado, 12) = TextBoxM

ListaPersonal.List(Seleccionado, 13) = ComboBoxInst

ListaPersonal.List(Seleccionado, 14) = ComboBoxSN

ListaPersonal.List(Seleccionado, 15) = ComboBoxSan


ListaPersonal.List(Seleccionado, 16) = TextBoxQ

ListaPersonal.List(Seleccionado, 17) = TextBoxR

ListaPersonal.List(Seleccionado, 18) = TextBoxEspe

ListaPersonal.List(Seleccionado, 19) = TextBoxDep

ListaPersonal.List(Seleccionado, 20) = TextBoxProv

ListaPersonal.List(Seleccionado, 21) = TextBoxDis

ListaPersonal.List(Seleccionado, 22) = TextBoxTel

ListaPersonal.List(Seleccionado, 23) = TextBoxCel1

ListaPersonal.List(Seleccionado, 24) = TextBoxCel2

ListaPersonal.List(Seleccionado, 25) = TextBoxFein

ListaPersonal.List(Seleccionado, 26) = TextBoxInmin

ListaPersonal.List(Seleccionado, 27) = TextBoxDir

ListaPersonal.List(Seleccionado, 28) = TextBoxDisd

ListaPersonal.List(Seleccionado, 29) = TextBoxCondi

ListaPersonal.List(Seleccionado, 9) = TextBoxId

Exit For

End If

Next

' TextBoxC = Format(Worksheets(“Familia”).Cells(TextBoxId, 3), "currency")

TextBoxG = Worksheets(“Familia”).Cells(TextBoxId, 7)

'TextBoxK = Format(Worksheets(“Familia”).Cells(TextBoxId, 11) * 100, "GENERAL


NUMBER")

If LabelNuevo.Caption = "NUEVO REGISTRO" Then

TotalPersonal = TotalPersonal + 1

End If

LabelNuevo.Caption = ""
ActiveWorkbook.Save

BuscarCodigo.SetFocus

End If

BuscarInst

BuscarGrado

ordenar

ActualizarIndice

End If

End Sub

Private Sub CommandButtonAgregar_Click()

ActualizarFoto ("")

LabelCodigo = ""

LabelNuevo.Caption = "NUEVO REGISTRO"

For CONTADOR = 1 To 100000

If Trim(Worksheets(“Familia”).Cells(CONTADOR, 1)) &


Trim(Worksheets(“Familia”).Cells(CONTADOR, 2)) & Trim(Worksheets(“Familia”).Cells(CONTADOR,
3)) = "" Then

TextBoxId = CONTADOR

Exit For

End If

Next

TextBoxA = ""

TextBoxB = ""
TextBoxC = ""

ComboBoxGra = ""

ComboBoxPla = ""

TextBoxF = ""

TextBoxG = Format(Date, "dd/mm/yyyy")

ComboBoxEstC = ""

ComboBoxArma = ""

TextBoxJ = ""

TextBoxK = ""

TextBoxL = ""

TextBoxM = ""

ComboBoxInst = ""

ComboBoxSN = ""

ComboBoxSan = ""

TextBoxQ = ""

TextBoxR = Format(Date, "dd/mm/yyyy")

TextBoxEspe = ""

TextBoxDep = ""

TextBoxProv = ""

TextBoxDis = ""

TextBoxTel = ""

TextBoxCel1 = ""

TextBoxCel2 = ""

TextBoxFein = Format(Date, "dd/mm/yyyy")

TextBoxInmin = Format(Date, "dd/mm/yyyy")

TextBoxDir = ""

TextBoxDisd = ""

TextBoxCondi = ""

TextBoxA.SetFocus
End Sub

Private Sub CommandButtonAgregar_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Te permite ingresar un nuevo producto, al finalizar tu captura para


guardar los cambios presiona boton verde ."

End Sub

Private Sub CommandButtonMisImagenes_Click()

Ruta = ThisWorkbook.Path

RutaCompleta = Ruta & "\Tools\Images\"

If Dir(RutaCompleta, vbDirectory) <> "" Then

ActiveWorkbook.FollowHyperlink Address:=RutaCompleta, NewWindow:=True

Else

MsgBox "Directorio no existe: " & RutaCompleta

MsgBox "Tus imagenes deben estar en este folder: " & RutaCompleta

End If

End Sub

Private Sub CommandButtonPortapapeles_Click()

'EsunEjemplo.SetText TextBoxB.Value

'EsunEjemplo.PutInClipboard

End Sub

Private Sub CommandButtonPortapapeles_MouseMove(ByVal Button As Integer, ByVal Shift As


Integer, ByVal X As Single, ByVal Y As Single)

FormaPersonal.Caption = "Copia en portapapeles la descripcion del producto"

End Sub

Private Sub ListaPersonal_Click()


If LabelNuevo = "NUEVO REGISTRO" Then

MsgBox "Los cambios no se guardaron"

LabelNuevo = ""

TextBoxA = ""

TextBoxB = ""

TextBoxC = ""

ComboBoxGra = ""

ComboBoxPla = ""

TextBoxF = ""

TextBoxG = Format(Date, "dd/mm/yyyy")

ComboBoxEstC = ""

ComboBoxArma = ""

TextBoxJ = ""

TextBoxK = ""

TextBoxL = ""

TextBoxM = ""

ComboBoxInst = ""

ComboBoxSN = ""

ComboBoxSan = ""

TextBoxQ = ""

TextBoxR = Format(Date, "dd/mm/yyyy")

TextBoxEspe = ""

TextBoxDep = ""

TextBoxProv = ""

TextBoxDis = ""

TextBoxTel = ""

TextBoxCel1 = ""

TextBoxCel2 = ""
TextBoxFein = Format(Date, "dd/mm/yyyy")

TextBoxInmin = Format(Date, "dd/mm/yyyy")

TextBoxDir = ""

TextBoxDisd = ""

TextBoxCondi = ""

End If

For CONTADOR = 0 To ListaPersonal.ListCount - 1

If ListaPersonal.Selected(CONTADOR) Then

ActualizarFoto (Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 2))

LabelCodigo = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 2))

TextBoxA = Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 1) 'DNI

TextBoxB = Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 2) 'APELLIDOS

TextBoxC = Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 3) 'NSA

ComboBoxGra = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 4))


'GRADO

ComboBoxPla = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 5))


'PLANA

TextBoxF = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 6)) 'NUESCA

If IsEmpty(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 7)) Then

TextBoxG.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxG = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 7))

End If

'TextBoxG = Format(Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 7)),


"dd/mm/yyyy") 'FENACI
ComboBoxEstC = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 8))
'ESTCIVIL

ComboBoxArma = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 9))


'INSTITUTO

TextBoxJ = Format(Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 10)),


"general number") 'PESO

TextBoxK = Format(Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 11)),


"Standard") 'TALLA

TextBoxL = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 12)) 'CTA

TextBoxM = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 13))


'BREVETE

ComboBoxInst = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 14))


'GRADO INST

ComboBoxSN = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 15))


'VEHICULO

ComboBoxSan = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 16))


'GRUSAN

TextBoxQ = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 17)) 'CCI

If IsEmpty(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 18)) Then

TextBoxR.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxR = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 18))

End If

'TextBoxR = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 18))


'FEULAS

TextBoxEspe = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 19))


'ESPECIALIDAD

TextBoxDep = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 20))


'DEPARTAMENTO

TextBoxProv = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 21))


'PROVINCIA
TextBoxDis = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 22))
'DISTRITO

TextBoxTel = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 23))


'TELEFONO

TextBoxCel1 = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 24))


'CELULAR1

TextBoxCel2 = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 25))


'CELULAR2

If IsEmpty(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 26)) Then

TextBoxFein.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxFein = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 26))

End If

If IsEmpty(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 27)) Then

TextBoxInmin.value = Format(Date, "dd/mm/yyyy")

Else

TextBoxInmin = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 27))

End If

'TextBoxFein = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 26))


'FECHA DE INGRESO INSTITUTO

'7extBoxInmin = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 27))


'FEC. INGRESO MINDEF

TextBoxDir = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 28))


'DIRECCION

TextBoxDisd = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 29))


'DISTRITO DONDE VIVE

TextBoxCondi = Trim(Worksheets(“Familia”).Cells(ListaPersonal.List(CONTADOR, 9), 30))


'CONDICION DE ALTA

TextBoxId = val(ListaPersonal.List(CONTADOR, 9))

End If
Next

End Sub

'Private Sub TextBoxG_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

'Dim sXLFile As String

'Dim sFolder As String

' Dim sWebsite As String

'sFolder = "C:\Temp\" ' You can change as per your requirement

'sXLFile = "C:\Temp\test1.xls" ' You can change as per your requirement

' sWebsite = TextBoxG.Value ' You can change as per your requirement

'ActiveWorkbook.FollowHyperlink "P:\Tree\Folder\Example.pdf"

'ActiveWorkbook.FollowHyperlink Address:=sFolder, NewWindow:=True 'Open Folder

'ActiveWorkbook.FollowHyperlink Address:=sXLFile, NewWindow:=True 'Open excel workbook

'ActiveWorkbook.FollowHyperlink "F:\Manuales pdf\PAF ULTRA-2.pdf"

' ActiveWorkbook.FollowHyperlink Address:=sWebsite, NewWindow:=True 'Open Website

'End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As


Single, ByVal Y As Single)

FormaPersonal.Caption = "Ventana actualizar productos"

End Sub
Function CodigoQR( _

ByVal PictureName As String, _

ByVal QR_Value As String, _

ByVal Renglon As Integer, _

ByVal Columna As Integer, _

Optional ByVal PictureSize As Long = 150, _

Optional ByVal DisplayText As String = "", _

Optional ByVal Updateable As Boolean = True) As Variant

Dim oPic As Shape, oRng As Excel.Range

Dim vLeft As Variant, vTop As Variant

Dim sURL As String

Const sRootURL As String = "https://chart.googleapis.com/chart?"

Const sSizeParameter As String = "chs="

Const sTypeChart As String = "cht=qr"

Const sDataParameter As String = "chl="

Const sJoinCHR As String = "&"

If Updateable = False Then

CodigoQR = "outdated"

Exit Function

End If

'Set oRng = Application.Caller.Offset(, 1) 'ORIGINAL

Set oRng = Application.Worksheets("Preferencias").Cells(Renglon, Columna).Offset(, 1)

On Error Resume Next


Set oPic = oRng.Parent.Shapes(PictureName)

If Err Then

Err.Clear

vLeft = oRng.Left + 4

vTop = oRng.Top

Else

vLeft = oPic.Left

vTop = oPic.Top

PictureSize = Int(oPic.Width)

oPic.Delete

End If

On Error GoTo 0

If Len(QR_Value) = 0 Then

CodigoQR = CVErr(xlErrValue)

Exit Function

End If

sURL = sRootURL & _

sSizeParameter & PictureSize & "x" & PictureSize & sJoinCHR & _

sTypeChart & sJoinCHR & _

sDataParameter & UTF8_URL_Encode(VBA.Replace(QR_Value, " ", "+"))

On Error GoTo SALIR

'Hoja3.Image1.Picture = Nothing

Worksheets("Preferencias").Select

ActiveSheet.Shapes.AddChart.Select

ActiveChart.ChartType = xlColumnClustered
ActiveSheet.Shapes(1).ScaleWidth 0.7672503574, msoFalse, msoScaleFromTopLeft

ActiveSheet.Shapes(1).ScaleHeight 1.2706530291, msoFalse, msoScaleFromTopLeft

ActiveSheet.Shapes(1).IncrementLeft 123.3333070866

ActiveSheet.Shapes(1).IncrementTop -145

ActiveSheet.Shapes(1).Line.Visible = msoFalse

Set oPic = oRng.Parent.Shapes.AddPicture(sURL, True, True, 200, 200, PictureSize,


PictureSize)

Application.Wait Now + 0.00001

oPic.Name = PictureName

CodigoQR = DisplayText

Set oPic = Nothing

Sheets("Preferencias").Select

ActiveSheet.Shapes.Range(Array("CodigoQR")).Select

Selection.Copy

Sheets("Preferencias").Select

ActiveSheet.ChartObjects(1).Activate

ActiveChart.Paste

Application.Wait Now + 0.00001

Worksheets("Preferencias").ChartObjects(1).Chart.Export Filename:=ThisWorkbook.Path &


"\Tools\Images\QR.jpg", FilterName:="JPG"

ActualizarFoto ("QR")

'Hoja3.Image1.Picture = LoadPicture(ThisWorkbook.Path & "\tools\images\QR.JPG")

Sheets("Preferencias").Select

Dim chrt As Chart

Dim ca As ChartArea
ActiveSheet.ChartObjects(1).Activate

ActiveChart.ChartArea.Copy

Set chrt = ActiveChart

Set ca = chrt.ChartArea

ca.Clear

Worksheets("Preferencias").Shapes.Range(Array("CodigoQR")).Delete

' PuntodeVenta.TextBoxCodigo.SetFocus

SALIR:

End Function

Public Function ConvertiraNumero(Valor As Variant) As Double

If IsNumeric(Valor) Then

ConvertiraNumero = val(Format(Valor, "general number"))

Else

ConvertiraNumero = 0

End If

End Function

You might also like