ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Popup commandbar and Setfocus (https://www.excelbanter.com/excel-programming/340975-popup-commandbar-setfocus.html)

Greg Wilson

Popup commandbar and Setfocus
 
I want to call a popup type commandbar and have it set the focus to a
control. The control is of type msoControlEdit. This does not seem to be
possible. Example code:

Dim cb As Commandbar
Set cb = Application.Commandbars("XYZ")
cb.Controls(3).Setfocus
cb.ShowPopup
'cb.Controls(3).Setfocus 'Alternatively place it here

My take on this is that it fails because you can't set the focus to an
invisible control and the controls are all invisible before the commandbar is
made visible with the ShowPopup method. If the SetFocus line follows the
ShowPopup line then it does not execute until the commandbar is dismissed, at
which point the controls are all invisible again.

Hoping I'm mistaken somehow or there is a workaround.

Greg

okaizawa

Popup commandbar and Setfocus
 
Hi,

one way:

SendKeys "{DOWN 3}"
cb.ShowPopup

I suppose it is hard to handle the focus in a normal way, as you said.

--
HTH,

okaizawa


Greg Wilson wrote:
I want to call a popup type commandbar and have it set the focus to a
control. The control is of type msoControlEdit. This does not seem to be
possible. Example code:

Dim cb As Commandbar
Set cb = Application.Commandbars("XYZ")
cb.Controls(3).Setfocus
cb.ShowPopup
'cb.Controls(3).Setfocus 'Alternatively place it here

My take on this is that it fails because you can't set the focus to an
invisible control and the controls are all invisible before the commandbar is
made visible with the ShowPopup method. If the SetFocus line follows the
ShowPopup line then it does not execute until the commandbar is dismissed, at
which point the controls are all invisible again.

Hoping I'm mistaken somehow or there is a workaround.

Greg


Greg Wilson

Popup commandbar and Setfocus
 
I worked !!!

I would have figured thought of doing it that way myself in about a week <g.

Best regards,
Greg


"okaizawa" wrote:

Hi,

one way:

SendKeys "{DOWN 3}"
cb.ShowPopup

I suppose it is hard to handle the focus in a normal way, as you said.

--
HTH,

okaizawa


Greg Wilson wrote:
I want to call a popup type commandbar and have it set the focus to a
control. The control is of type msoControlEdit. This does not seem to be
possible. Example code:

Dim cb As Commandbar
Set cb = Application.Commandbars("XYZ")
cb.Controls(3).Setfocus
cb.ShowPopup
'cb.Controls(3).Setfocus 'Alternatively place it here

My take on this is that it fails because you can't set the focus to an
invisible control and the controls are all invisible before the commandbar is
made visible with the ShowPopup method. If the SetFocus line follows the
ShowPopup line then it does not execute until the commandbar is dismissed, at
which point the controls are all invisible again.

Hoping I'm mistaken somehow or there is a workaround.

Greg




All times are GMT +1. The time now is 01:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com