Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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.Path imagen = 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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 91: Object variable or With block variable not set
Try...
Private Sub ComboBox1_Change() Dim fso As Object, rngFound As Range Dim ruta$, imagen$, ruta_e_imagen$ 'type=String Set fso = CreateObject("Scripting.FileSystemObject") ruta = ActiveWorkbook.Path imagen = ComboBox1.List(ComboBox1.ListIndex) & ".jpg" ruta_e_imagen = ruta & "\FOTOS\" & imagen If fso.FileExists(ruta_e_imagen) Then Image1.Picture = LoadPicture(ruta_e_imagen) Set rngFound = Cells.Find(What:=Replace(imagen, ".jpg", "")) If rngFound Is Nothing Then GoTo NotFound With rngFound Label3 = .Offset(0, 1): Label2 = .Offset(0, 2) Label12 = .Offset(0, 10): Label13 = .Offset(0, 11) Label14 = .Offset(0, 12): Label15 = .Offset(0, 13) Label16 = .Offset(0, 14) End With 'rngFound Else GoTo NotFound End If NormalExit: Exit Sub NotFound: MsgBox "La Imagen: " & imagen & ", NO está disponible" End Sub -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 91: Object variable or With block variable not set
GS wrote:
This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com Hey Garry, do me a favor. Kill that line, if possible. -- I've come to realize tonight, my friend, the end of time is not so far away. We cannot pray to save our lives. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 91: Object variable or With block variable not set
GS wrote:
This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com Hey Garry, do me a favor. Kill that line, if possible. Uh.., that was anoying me but didn't think anyone would care. I think it's gone now! Thanks for the nudge! ;-) -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 91: Object variable or With block variable not set
GS wrote:
GS wrote: This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com Hey Garry, do me a favor. Kill that line, if possible. Uh.., that was anoying me but didn't think anyone would care. I think it's gone now! Thanks for the nudge! ;-) Np. It was just a minor thing, really. -- Your face just broke the language barrier. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 91: Object variable or With block variable not set
My macro doesn't work if sheet is protected but it works if not protected what can i do?
|
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 91: Object variable or With block variable not set
From a previous post...
There's no reason to toggle protection when you reset protection when the file is first opened. Make sure you set 'UserInterfaceOnly:=True' so your code can modify the sheet but the user can't via the UI. Make sure your code includes 'AllowFiltering:=True' OR set 'worksheet.EnableAutoFilter:=True'... Dim wks As Variant For Each wks In ActiveWorkbook.Worksheets wks.Unprotect <password wks.Protect Password:=<password, UserInterfaceOnly:=True, _ AllowFiltering:=True '//add more as req'd Next 'wks It's feasible, however, that not all sheets need/are protected in a file so you may want to use a string constant of delimited sheetnames that protection is applied to... Const sSheetsToProtect$ = "Sheet1,Sheet2,Sheet4" Dim vName As Variant For Each wks In Split(sSheetsToProtect$, ",") Sheets(vName).Unprotect <password Sheets(vName).Protect Password:=<password, _ UserInterfaceOnly:=True, _ AllowFiltering:=True '//add more as req'd Next 'wks HTH -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 91: Object variable or With block variable not set
Sorry.., wrong thread!
-- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 91: Object variable or With block variable not set
I think something is wrong in my code to protect and no to protect:
Code: Sub protegida () (TO PROTECT) Application.ScreenUpdating = False pw = "protegida" Hoja1.Select For i = 1 To Sheets.Count Sheets(i).Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowSorting:=treu, AllowFiltering:=True, AllowUsingPivotTables:=True Next i Dim wsSheet As Worksheet For Each wsSheet In ActiveWorkbook.Worksheets If wsSheet.Name < Hoja1.Name Then wsSheet.Visible = xlSheetVeryHidden End If Next wsSheet End Sub Sub edicion()(NOT TO PROTECT) Application.ScreenUpdating = False Hoja1.Select For i = 1 To Sheets.Count Sheets(i).Protect DrawingObjects:=False, Contents:=False, Scenarios:=False _ , AllowSorting:=False, AllowFiltering:=False, AllowUsingPivotTables:=False Next i Dim wsSheet As Worksheet For Each wsSheet In ActiveWorkbook.Worksheets If wsSheet.Name < Hoja1.Name Then wsSheet.Visible = xlSheetVisible End If Next wsSheet End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime Error '91' Object variable or With block variable not set | Excel Discussion (Misc queries) | |||
Runtime Error 91 Object variable or With block variable not set. | Excel Programming | |||
Error Number: 91 object variable or With block Variable not set | Excel Programming | |||
Run-time error '91': "Object variable or With block variable not set | Excel Programming | |||
Cells.Find error Object variable or With block variable not set | Excel Programming |