View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default Refedit Retaining Focus

I've had this problem and found changing focus helps:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If ActiveControl.Name = "MyRefEdit" Then NamesListBox.SetFocus
End Sub

Doing it in the terminate event is too late I believe.

--
Jim
"Pflugs" wrote in message
...
|I created a userform that contains a RefEdit, several textboxes, and a
'Done'
| button. The form is initialized with the RefEdit as the focus. The form
| also has a checkbox that when clicked modifies the width to reveal a
second
| set of controls.
|
| Sometimes when I click 'Done' to close the form, the RefEdit's selection
| retains control. That is, the status bar says "Point" and the ants are
| marching around the selection. When this happens, the macro continues to
run
| and Excel becomes confused and eventually crashes.
|
| I'm not sure why this is happening. I have even used
| "Application.CutCopyMode = False" on Terminate, and that doesn't seem to
take
| care of all problems. I have also tried cleaning the code with Rob
Bovey's
| Code Cleaner. Any other suggestions?
|
| Thanks,
| Pflugs