How to force selection to show onscreen before MsgBox executed?

  • Thread starter Thread starter Dave Jenkins
  • Start date Start date
D

Dave Jenkins

I've got an application that selects a shape, and then issues a MsgBox
function call to get user input as to how the shape should be handled. When
I run the code, the MsgBox comes up, but the shape doesn't show that it's
selected. If I Cancel the MsgBox, the handles on the shape magically appear.
If I run the code in Debug, the handles appear *before* the MsgBox gets
executed.

Is there a way to force a refresh or update or something when the code is
running freely, so that by the time the MsgBox pops up, the shape will show
its proper selection status?

Thanks.
 
Steve Rindsberg said:
Sometimes a DoEvents (or two. or five.) yields enough time to PPT for it to
update the display.

Thanks, Steve. I tried inserting a DoEvents after the Select, and before
the MsgBox, and it didn't seem to help. You're saying to repeat the
DoEvents? I don't mind doing that - is there anything I can test to see if
the Select has "taken" to end the loop with?

This is really clumsy ...
 
I doubt there is a test you can run to see if the selection status has
taken effect because I believe this is a display issue, not an actual
selection issue. That is, the object is actually selected, it just isn't
being displayed as being selected. I wonder if a little loop to delay
for 1 second would work. Something like this:

Sub Wait()
waitTime = 1
Start = Timer
While Timer < Start + waitTime
DoEvents
Wend
End Sub
 
David Marcovitz said:
I doubt there is a test you can run to see if the selection status has
taken effect because I believe this is a display issue, not an actual
selection issue. That is, the object is actually selected, it just isn't
being displayed as being selected. I wonder if a little loop to delay
for 1 second would work. Something like this:

Sub Wait()
waitTime = 1
Start = Timer
While Timer < Start + waitTime
DoEvents
Wend
End Sub


I don't know, David - I'll give it a try!

[Time passess ...]

That seems to work, David, but I'm still doing some testing to see if it
_always_ works.

There may be something else at work here, above and beyond a requisite time
delay.
I have found that on certain slides, with certain shapes, it doesn't matter
_how long_ of a delay I induce, the shape will not be selected (display-wise
speaking) when the msgbox comes up. BUT: If I go on to the next shape on that
slide (and the rest in the file, for that matter), the shape concerned _will_
show as selected. And then when I rerun the macro from the start, it _does_
work on that slide and that shape.

I'm trying to pin down whether that's an artifact of the various versions of
the program I've been dealing with, or what.

I'll post again if I can be a little crisper in my problem definition. In
the meantime, thanks again.
 
It seems you use Inputbox to get user input. Using several DoEvents
eventually will work but you can also use modeless userforms instead of
Inputbox and it that case you won’t need any DoEvents or a delay procedure.
Insert a userform with a textbox and as many buttons as you need and
immediately after your selection code run the following code
Userform1.Show (modeless)
and get user input in this userform instead of an Inputbox
 
Edward said:
It seems you use Inputbox to get user input. Using several DoEvents
eventually will work but you can also use modeless userforms instead of
Inputbox and it that case you won’t need any DoEvents or a delay procedure.
Insert a userform with a textbox and as many buttons as you need and
immediately after your selection code run the following code
Userform1.Show (modeless)
and get user input in this userform instead of an Inputbox

Hi Edward:

I had toyed with that, but just hadn't stirred myself. Further, I didn't
know if it would actually cure the problem I was having. I think I'll take
your advice, and it will be cleaner all the waya round, since I make
extensive use of user forms elsewhere, and they look different than MsgBoxes
anyway - this way I can tend to be more consistent.

Thanks.
 
I guess my previous pose got lost somewhere ! It seems you are using Inputbox
to get user input. DoEvents and long delays might eventually work, but the
better approach is using modeless userforms to get user input.
Insert a userform with a textbox and as many buttons as you need then after
your selection code use the following code
Userform1.Show(modeless)
And get user input in this userform instead of an Inputbox.
Now sleected shape will show as selected when userform loads.

--
Best regards,
Edward


Dave Jenkins said:
David Marcovitz said:
I doubt there is a test you can run to see if the selection status has
taken effect because I believe this is a display issue, not an actual
selection issue. That is, the object is actually selected, it just isn't
being displayed as being selected. I wonder if a little loop to delay
for 1 second would work. Something like this:

Sub Wait()
waitTime = 1
Start = Timer
While Timer < Start + waitTime
DoEvents
Wend
End Sub


I don't know, David - I'll give it a try!

[Time passess ...]

That seems to work, David, but I'm still doing some testing to see if it
_always_ works.

There may be something else at work here, above and beyond a requisite time
delay.
I have found that on certain slides, with certain shapes, it doesn't matter
_how long_ of a delay I induce, the shape will not be selected (display-wise
speaking) when the msgbox comes up. BUT: If I go on to the next shape on that
slide (and the rest in the file, for that matter), the shape concerned _will_
show as selected. And then when I rerun the macro from the start, it _does_
work on that slide and that shape.

I'm trying to pin down whether that's an artifact of the various versions of
the program I've been dealing with, or what.

I'll post again if I can be a little crisper in my problem definition. In
the meantime, thanks again.
 
Edward said:
It seems you use Inputbox to get user input. Using several DoEvents
eventually will work but you can also use modeless userforms instead of
Inputbox and it that case you won’t need any DoEvents or a delay procedure.
Insert a userform with a textbox and as many buttons as you need and
immediately after your selection code run the following code
Userform1.Show (modeless)
and get user input in this userform instead of an Inputbox


Actually, I've been using MsgBox. Don't know if InputBox would have made
any difference.

Here's the results of what I did last night: I converted the code to use a
modal form - thought I'd get that working before shifting to modeless.
Having made that change, it all started working ok, and so I see no
requirement to convert to a modeless user form. (Although it seems
counter-intuitive, for isn't a MsgBox simply a modal form provided in the
language?)

I did notice one other behavior of the previous code: When the code selected
the *first* shape, it usually didn't matter how long a delay I induced
(actually, I tested up to a 5 second delay) between the Select and the MsgBox
- the shape did not display as being selected until after the MsgBox was
cleared. But once it started showing the subsequent selections, they would
all show prior to the associated MsgBox. It's as though the first instance
triggered some sort of global latch which enabled the selection display on
the second and succeeding instances.

Anyway, for the time-being I'm back in business (but not particularly
wiser). Thanks for your help (and Steve's and David's, too).
 
Oh okay I thought user is typing in something, that's why I said Inputbox .
Yes msgbox is modal form but it is created using API MessageBox function but
userforms are completely different animals under ThunderDFrame class.
 
Back
Top