My macro doesn't work if sheet is protected but it works if not protected


A

anapaulags92

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
 
Ad

Advertisements

C

Claus Busch

Hi,

Am Tue, 11 Feb 2014 07:52:43 -0800 (PST) schrieb (e-mail address removed):
Cells.Find(What:=Replace(imagen, ".jpg", "")).Select <<----((ERROR HERE)
Label3 = ActiveCell.Offset(0, 1)
Label2 = ActiveCell.Offset(0, 2)

try:

set c =Cells.Find(What:=Replace(imagen, ".jpg", ""))
Label3 = c.Offset(0, 1)
Label2 = c.Offset(0, 2)
..
..


Regards
Claus B.
 
Ad

Advertisements

A

anapaulags92

I tried your code but the error is now here:


Set c = Cells.Find(What:=Replace(imagen, ".jpg", ""))

Label3 = c.Offset(0, 1) <<<--- ERROR HERE
Label2 = c.Offset(0, 2)
Label12 = c.Offset(0, 10)
Label13 = c.Offset(0, 11)
Label14 = c.Offset(0, 12)
Label15 = c.Offset(0, 13)
Label16 = c.Offset(0, 14)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top