No se ha definido la variable

Tengo este código para ocultar tablas y consultas, pero a la hora de que se genera el evento me manda el mensaje de que no se ha definido la variable y se refiere a myObject, qué puedo tener mal?

Public Sub Ocultar()
For Each myObject In Application.CurrentData.AllTables
If Not (myObject.Name Like "Msys*") Then
Application.SetHiddenAttribute acTable, myObject.Name, True
End If
Next myObject

For Each myObject In Application.CurrentData.AllQueries
If Not (myObject.Name Like "Msys*") Then
Application.SetHiddenAttribute acTable, myObject.Name, True
End If
Next myObject

Gracias por el apoyo
End Sub

Añade tu respuesta

Haz clic para o