Macro para mostrar Imágenes jpg O jpeg
Recurro a su conocimiento porque no se como resolver este problema. La cuestión es que tengo las imágenes en un directorio y algunas con jpg y otras jpeg, por lo cual debería buscar por una extensión y si no lo encuentra con esa, buscar con la otra. No se como escribir para darme cuenta que si no lo encontró lo busque con la otra extensión. ¿Me podrán ayudar? Muchas Gracias! Oscar.
La rutina que uso:
Sub busca_imagen_3000()
Application.ScreenUpdating = False
Dim codigo As String
Dim cod2 As String
Dim Pic As Shape
ActiveSheet.Pictures.Select
Selection.Delete
Range("B2").Select
codigo = Left(Cells(ActiveCell.Row, 1), 6) & "_" & Right(Cells(ActiveCell.Row, 1), 2)
While Cells(ActiveCell.Row, 1) <> Empty
ActiveCell.RowHeight = 45 '105
ActiveCell.ColumnWidth = 9 '24
ruta = "\\buefs01\common files\FotosSKU\" ' carpeta adicional con las fotos, fuera de la red
On Error GoTo NoEncontrado:
ActiveSheet.Pictures.Insert(ruta & codigo & ".jpg").Select
On Error GoTo NoEncontrado:
With Selection
.ShapeRange.LockAspectRatio = msoFalse
.Top = ActiveCell.Top + 5
.Left = ActiveCell.Left + 5
.ShapeRange.Height = ActiveCell.Height - 10
.ShapeRange.Width = ActiveCell.Width - 10
End With
NoEncontrado:
Resume 1
1:
codigo = Left(Cells(ActiveCell.Row + 1, 1), 6) & "_" & Right(Cells(ActiveCell.Row + 1, 1), 2)
Cells(ActiveCell.Row + 1, 2).Select
Wend
ActiveSheet.Pictures.Select
On Error GoTo Nohayfoto:
With Selection
.Placement = xlMoveAndSize
.PrintObject = True
End With
Nohayfoto:
Resume 2
2:
Application.ScreenUpdating = True
End Sub