View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] anapaulags92@gmail.com is offline
external usenet poster
 
Posts: 6
Default My macro doesn't work if sheet is protected but it works if not protected

Runtime error 91: Object variable or With block variable not set

My code is


Private Sub ComboBox1_Change()

Dim fso As Object

Set fso = CreateObject("Scripting.FileSystemObject")

ruta = ActiveWorkbook.Pathimagen = ComboBox1.List(ComboBox1.ListIndex) & ".jpg"

ruta_e_imagen = ruta & "\FOTOS\" & imagen
If fso.FileExists(ruta_e_imagen) Then

Image1.Picture = LoadPicture(ruta_e_imagen)


Cells.Find(What:=Replace(imagen, ".jpg", "")).Select <<----((ERROR HERE)
Label3 = ActiveCell.Offset(0, 1)
Label2 = ActiveCell.Offset(0, 2)
Label12 = ActiveCell.Offset(0, 10)
Label13 = ActiveCell.Offset(0, 11)
Label14 = ActiveCell.Offset(0, 12)
Label15 = ActiveCell.Offset(0, 13)
Label16 = ActiveCell.Offset(0, 14)

Else

MsgBox "La Imagen: " & imagen & ", NO está disponible"

End If

End Sub