Modeless form keeps taking 'focus'

M

Michelle

I'm using a modeless form in Excel 2007, I want to be able to scroll around
Excel and occasionally select something from the form. But when I use the
form, the form gets 'focus' and things (like the mouse-wheel) don't apply to
the application anymore.

Is there a way to hand focus back to the application? Or is there a way so
set the form so that it doesn't take this 'focus'?

Thanks

Michelle
 
J

Jim Rech

When you show a modeless userform it takes the focus but after you click to
Excel the form never takes it back on its own. I don't know that you can
avoid the initial taking focus if that's what you mean.

--
Jim
| I'm using a modeless form in Excel 2007, I want to be able to scroll
around
| Excel and occasionally select something from the form. But when I use the
| form, the form gets 'focus' and things (like the mouse-wheel) don't apply
to
| the application anymore.
|
| Is there a way to hand focus back to the application? Or is there a way so
| set the form so that it doesn't take this 'focus'?
|
| Thanks
|
| Michelle
|
 
D

Dave Peterson

Maybe you can cheat just a little.

I put this under the userform:

Option Explicit
Private Sub UserForm_Initialize()
Application.OnTime Now + TimeSerial(0, 0, 1), "SelectACell"
End Sub

And this in a general module:
Option Explicit
Sub testme()
UserForm1.Show False
End Sub
Sub SelectACell()
AppActivate Application.Caption
End Sub

It seemed to work ok in my simple testing.
 
J

Jim Rech

Cool!

--
Jim
| Maybe you can cheat just a little.
|
| I put this under the userform:
|
| Option Explicit
| Private Sub UserForm_Initialize()
| Application.OnTime Now + TimeSerial(0, 0, 1), "SelectACell"
| End Sub
|
| And this in a general module:
| Option Explicit
| Sub testme()
| UserForm1.Show False
| End Sub
| Sub SelectACell()
| AppActivate Application.Caption
| End Sub
|
| It seemed to work ok in my simple testing.
|
|
| Michelle wrote:
| >
| > I'm using a modeless form in Excel 2007, I want to be able to scroll
around
| > Excel and occasionally select something from the form. But when I use
the
| > form, the form gets 'focus' and things (like the mouse-wheel) don't
apply to
| > the application anymore.
| >
| > Is there a way to hand focus back to the application? Or is there a way
so
| > set the form so that it doesn't take this 'focus'?
| >
| > Thanks
| >
| > Michelle
|
| --
|
| Dave Peterson
 
M

Michelle

OK, thank you, I have taken a while to get it to work because in 2007 the
caption sometimes also includes "[Compatibility Mode]" so it didn't work for
some files, but it does work with:
AppActivate "Microsoft Excel - " & ThisWorkbook.name

Thank you

M
 
D

Dave Peterson

I would have guessed that application.caption would have caught this.

But glad you got it working.
OK, thank you, I have taken a while to get it to work because in 2007 the
caption sometimes also includes "[Compatibility Mode]" so it didn't work for
some files, but it does work with:
AppActivate "Microsoft Excel - " & ThisWorkbook.name

Thank you

M

Dave Peterson said:
Maybe you can cheat just a little.

I put this under the userform:

Option Explicit
Private Sub UserForm_Initialize()
Application.OnTime Now + TimeSerial(0, 0, 1), "SelectACell"
End Sub

And this in a general module:
Option Explicit
Sub testme()
UserForm1.Show False
End Sub
Sub SelectACell()
AppActivate Application.Caption
End Sub

It seemed to work ok in my simple testing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top