Riddle me this.... at the command line in 2018 this works.
Command: DYNMODE
Enter new value for DYNMODE <-3>: 3
Command: SETVAR
Enter variable name or [?] <DYNMODE>:
Enter new value for DYNMODE <3>: -3
Command: (setq *doc* (vla-get-activedocument (vlax-get-acad-object)))
#<VLA-OBJECT IAcadDocument 00000000293ddd08>
Command: (vla-setvariable *doc* "dynmode" 3) ;;<<<<<works in earlier versions
; error: Automation Error. Error setting system variable;;; yet 2018 throws this