Access - Error '438' en Excel

 
Vista:

Error '438' en Excel

Publicado por Lucas (1 intervención) el 20/09/2011 04:51:27
Hola, hice una Macro que adjunta una foto en un lugar y en un tamaño determinado, el tema es que cuando el usuario se arrepiente y en vez de adjuntar una imagen, hace clic en cancelar sale error '438'.-
Deseo que eso no aparezca.- y pueda cancelar sin que le salga esa leyenda.-
Que esta mal o me falta ?
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
Sub InsertarArchImagen1()
 
Application.Dialogs(xlDialogInsertPicture).Show
  Control = Range("CA12").Value
    If Control <> "" Then
        For i = 12 To 16
            Nombre = Range("CA" & i).Value
            On Error Resume Next
            ActiveSheet.Shapes(Nombre).Select
            ActiveSheet.Shapes(Nombre).Delete
        Next
    Else
    End If
Selection.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
Selection.ShapeRange.PictureFormat.CropLeft = 10
Selection.ShapeRange.PictureFormat.CropRight = 10
Selection.ShapeRange.PictureFormat.CropTop = 20
Selection.ShapeRange.PictureFormat.CropBottom = 20
tope = Range("B48:J64").Top
izq = Range("B48:J64").Left
alto = Range("B48:J64").Height
ancho = Range("B48:J64").Width
Selection.ShapeRange.Top = tope
Selection.ShapeRange.Left = izq
Selection.ShapeRange.Height = alto
Selection.ShapeRange.Width = ancho
For i = 1 To columna
anchototal = anchototal + Cells(i, 1).ColumnWidth
Next
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 '438' en Excel

Publicado por Vicente (4 intervenciones) el 20/09/2011 16:49:06
Hola Lucas, el error se produce cuando el usuario no inserta ninguna imágen por lo que podrías utilizar una variable de tipo Boolean para controlar si se produce o no la inserción. Por ejemplo:

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
Sub InsertarArchImagen1()
 
Dim x As Boolean    ' variable para controlar la inserción de imágen
 
x = Application.Dialogs(xlDialogInsertPicture).Show
 
If  x = True Then   ' si se produce la inserción
 
    Control = Range("CA12").Value
    If Control <> "" Then
        For i = 12 To 16
            Nombre = Range("CA" & i).Value
            On Error Resume Next
            ActiveSheet.Shapes(Nombre).Select
            ActiveSheet.Shapes(Nombre).Delete
        Next
        Else
    End If
    Selection.ShapeRange.PictureFormat.Brightness = 0.5
    Selection.ShapeRange.PictureFormat.Contrast = 0.5
    Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
    Selection.ShapeRange.PictureFormat.CropLeft = 10
    Selection.ShapeRange.PictureFormat.CropRight = 10
    Selection.ShapeRange.PictureFormat.CropTop = 20
    Selection.ShapeRange.PictureFormat.CropBottom = 20
    tope = Range("B48:J64").Top
    izq = Range("B48:J64").Left
    alto = Range("B48:J64").Height
    ancho = Range("B48:J64").Width
    Selection.ShapeRange.Top = tope
    Selection.ShapeRange.Left = izq
    Selection.ShapeRange.Height = alto
    Selection.ShapeRange.Width = ancho
    For i = 1 To columna
    anchototal = anchototal + Cells(i, 1).ColumnWidth
    Next
 
End If
 
End Sub


Un saludo,
Vicente.
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

Error

Publicado por javier (1 intervención) el 16/02/2013 20:58:31
tengo el mismo problema esta es mi linea de codigo

Private Sub CommandButton2_Click()



Application.Dialogs(xlDialogInsertPicture).Show

tope = Range("A12:O27").Top
izq = Range("A12:O27").Left
alto = Range("A12:O27").Height
ancho = Range("A12:O27").Width
Selection.ShapeRange.Top = tope
Selection.ShapeRange.Left = izq
Selection.ShapeRange.Height = alto
Selection.ShapeRange.Width = ancho

End Sub
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