Attempting to set focus on next logical textbox from code in current textbox using VBA in Word2016 running windows 10 on a Dell Laptop.
My test form has two text boxes with default names Textbox1 and Textbox2.
Code:
Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
TextBox2.SetFocus
End Sub
Message from TextBox1MouseDown sub is
Quote:
Run-time error '-2147417848(80010108)':
Automation error
The object invoked has disconnected from its clients.
|
(I have screen shots in my word folder, but I find that the insert Image icon in this editor requires an URL )
I can close the dialog and form. But when I try to close the word document I get a messagebox
Quote:
You cannot close Microsoft Word because a dialog box is open.
Click OK, switch to Word, then close the dialog box.
|
But there is no other dialog box visible -- forcing me to invoke the task manager and manually end the Word task.
Curiously, I have no problem using setfocus within my command button Click sub.
When I remove the setfocus, the text1 box remains active and the user must tab. So it's not a crisis, just tacky.