After running your version of the AppleScript code several times, the command open myfile password document
actually worked for me maybe 3 or 4 sporadic times. Eventually it stopped working and the password dialog box opened every time. After wracking my brain trying to figure out why this was happening, for nearly an hour, I reluctantly decided to use UI scripting to handle the password dialog box, in the event it reared its ugly head.
This AppleScript code works for me using the latest version of macOS Mojave and Microsoft Word version 16.24
set the myfile to (path to desktop as text) & "teste.docx"
set thePassword to 123
tell application "Microsoft Word"
activate
ignoring application responses
open myfile password document thePassword
delay 1
end ignoring
end tell
try
tell application "System Events"
repeat until exists of window "Password" of application process "Word"
delay 0.1
end repeat
click window "Password" of application process "Word"
delay 0.2
click text field 1 of window "Password" of application process "Word"
delay 0.2
keystroke thePassword
delay 0.2
keystroke return
end tell
end try