hi,
the code doesn't give me an error on the pc (32bit OS) but it intermittently gets an error 80010108 in my lap top (64 bit OS), both excels are 32bit.
the code is:
Private Sub Workbook_Open()
Dim version As String, fecha As Date, permiso As Boolean
bloqCh = True 'I use this variable to stop combobox_change() event
version = "1.000"
fecha = getVersion(version) 'query to db to check if the app hasn't expired
If fecha < Now() Then
merror = MsgBox("¡Esta versión ya no es válida, solicite la actualización!", vbCritical, "Versión Antigua")
ActiveWorkbook.Close SaveChanges:=False
Else
Application.Run "bloqSheet", "Listas", False 'deactive protection in worksheet "listas"
Application.Run "bloqSheet", "Reporte", False 'deactivate protection in worksheets "reporte"
Application.EnableEvents = True
Call setNames 'assign named ranges to combobox.listfillrange
Call getArea 'query to db and copy to range
Call bloqCab(False) 'range.lock
Call bloqCaptura(True) 'range.lock
Application.Run "bloqSheet", "Listas", True 'activate protection
Application.Run "bloqSheet", "Reporte", True 'activate protection
bloqCh = False
End If
End Sub
I get the error inside the function: getArea
Public Function getArea()
Dim ran As Range, sqlStr As String
ActiveWorkbook.Worksheets("Listas").Range("a3:b1000") = "" 'GIVES ERROR
Set ran = Worksheets("Listas").Range("a3")
sqlStr = "SELECT [Id_Area], [Area] FROM [Area] ORDER BY [Area];"
Call sQuery(sqlStr, ran) 'query to db an copy recordset in ran
'count records, update named range, assign named range to combobox.listfillrange
fin = Application.WorksheetFunction.CountA(Worksheets("Listas").Range("a:a"))
ActiveWorkbook.Names("Area").RefersToR1C1 = "=Listas!R3C1:R" & fin & "C2"
Worksheets("Reporte").cbArea.ListFillRange = "Area"
End Function
all the functions called in workbook_open are located in a module
when i get the error if go to the code and restart the execution (F5), the code resumes properly without giving the error and i can continue working in the workbook as if it never happened. but, when i close the workbook excel crashes
i used the codecleaner www.appspro.com/Utilities/CodeCleaner.htm , but it only help a little, the error continues appearing, but less often.
thanks for any help
Bookmarks