diff --git a/animation_animall.py b/animation_animall.py
index e291799e9bbcdc28e10b338f41a44ad1f39bdf12..c20f64b1adc5f704fa868a00eab101354ecbc70a 100644
--- a/animation_animall.py
+++ b/animation_animall.py
@@ -198,10 +198,18 @@ class ANIM_OT_insert_keyframe_animall(bpy.types.Operator):
                 bpy.ops.object.editmode_toggle()
         
         if Obj.type == 'LATTICE':
+            Mode = False
+            if context.mode != 'OBJECT':
+                Mode = not Mode
+                bpy.ops.object.editmode_toggle()
+            
             if context.window_manager.key_shape:
                 if Obj.active_shape_key:
                     for Point in Obj.active_shape_key.data:
                         Point.keyframe_insert('co')
+            
+            if Mode:
+                bpy.ops.object.editmode_toggle()
         
         if Obj.type == 'CURVE':
             Mode = False