Visual Basic para Aplicaciones - error n°53

Life is soft - evento anual de software empresarial
 
Vista:
Imágen de perfil de juan marcelo
Val: 7
Ha aumentado su posición en 4 puestos en Visual Basic para Aplicaciones (en relación al último mes)
Gráfica de Visual Basic para Aplicaciones

error n°53

Publicado por juan marcelo (2 intervenciones) el 09/04/2018 18:07:15
Buenas, tengo este código dentro de un botón que busca los registros con sus respectivas fotos. El problema es que cuando un registro no tiene foto, me tira el siguiente mensaje: 'error 53 en tiempo de ejcución archivo no encontrado' y no puedo solucionarlo. Alguien me puede ayudar?, gracias!!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Sub consultarRegistro()
Dim ultfila As Long
Dim rango As String
Dim filaRegistro As Long
Dim mat As String
Dim apell_nom As String
Dim nroPrio As String
Dim unidad As String
Dim pab As String
Dim Sit_Leg As String
Dim rutaImagen As String
Dim Procedencia As String
Dim Circunscrip As String
Dim ingresoUnidad As String
Dim causa As String
Dim juzgado As String
Dim condena As String
Dim imagenFija As String
 
   rutaImagen = ActiveWorkbook.Path & "\carpetadeimagenes\"
 
 
   ultfila = Range("C" & Rows.Count).End(xlUp).Row
   rango = "C3:C6000" & ultfila
 
    If Len(frmIngresoDatos.txtApell_nom) = 0 Then
        MsgBox "No ingresó datos para la búsqueda!"
        Exit Sub
    End If
 
    filaRegistro = filaExisteRegistro(frmIngresoDatos.txtApell_nom, rango)
    If filaRegistro = 0 Then
        MsgBox "No se encontró el registro en la base de datos!"
        Exit Sub
    End If
 
 
    mat = indiceGral.Cells(filaRegistro, 2)
    apell_nom = indiceGral.Cells(filaRegistro, 3)
    nroPrio = indiceGral.Cells(filaRegistro, 4)
    unidad = indiceGral.Cells(filaRegistro, 5)
    pab = indiceGral.Cells(filaRegistro, 6)
    Sit_Leg = indiceGral.Cells(filaRegistro, 7)
    Ur = indiceGral.Cells(filaRegistro, 8)
    ingScio = indiceGral.Cells(filaRegistro, 9)
    Procedencia = indiceGral.Cells(filaRegistro, 10)
    Circunscrip = indiceGral.Cells(filaRegistro, 11)
    ingresoUnidad = indiceGral.Cells(filaRegistro, 12)
    causa = indiceGral.Cells(filaRegistro, 13)
    juzgado = indiceGral.Cells(filaRegistro, 15)
    condena = indiceGral.Cells(filaRegistro, 16)
 
    frmIngresoDatos.txtMat = mat
    frmIngresoDatos.txtApell_nom = apell_nom
    frmIngresoDatos.txtPrio = nroPrio
    frmIngresoDatos.txtUnidad = unidad
    frmIngresoDatos.txtPab = pab
    frmIngresoDatos.txtSit_Leg = Sit_Leg
    frmIngresoDatos.txtUr = Ur
    frmIngresoDatos.txtIngScio = ingScio
    frmIngresoDatos.txtProcedencia = Procedencia
    frmIngresoDatos.txtCirc = Circunscrip
    frmIngresoDatos.txtIngUnidad = ingresoUnidad
    frmIngresoDatos.txtCausa = causa
    frmIngresoDatos.txtJuz = juzgado
    frmIngresoDatos.txtCond = condena
 
    frmIngresoDatos.imgInternos.Picture = LoadPicture(rutaImagen & frmIngresoDatos.txtPrio & ".jpg")
 
 
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

error n°53

Publicado por JuanC (565 intervenciones) el 09/04/2018 23:16:10
hay varias maneras de solucionarlo, la más simple (y no siempre recomendada) es usar On Error Resume Next
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Antoni Masana
Val: 1.134
Oro
Ha mantenido su posición en Visual Basic para Aplicaciones (en relación al último mes)
Gráfica de Visual Basic para Aplicaciones

error n°53

Publicado por Antoni Masana (498 intervenciones) el 10/04/2018 06:40:31
Una solución más limpia

1
2
3
4
5
6
7
8
9
10
11
Sub consultarRegistro()
    ...
    frmIngresoDatos.txtJuz = juzgado
    frmIngresoDatos.txtCond = condena
 
    If Dir(rutaImagen & frmIngresoDatos.txtPrio & ".jpg")="" Then
        MsgBox "No existe la Imagen:" & VbCrLf & rutaImagen & frmIngresoDatos.txtPrio & ".jpg"
    Else
        frmIngresoDatos.imgInternos.Picture = LoadPicture(rutaImagen & frmIngresoDatos.txtPrio & ".jpg")
    End If
End Sub

Saludos.
\\//_
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar