Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Pausing Code

Hi All
I currently have an application code that uses a series of MsgBox to ask
user to accept or not specific actions. Such as "Data for Dec07 is already
loaded, overwrite?", a Yes / No option then determines the next step.
This works ok.

I have now decided to incorporate a UserForm, with labels acting as messages
and command buttons to decide actions. Unlike the MsgBox which halts the
code this method does not pause. Rather than have to re-engineer the entire
code, I was looking for suggestions as to how to proceed.


--

Regards,
Nigel




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Pausing Code

Nigel,

A user form can be displayed modally or modelessly. When it is displayed
modally, with code like

UserForm1.Show vbModal

the code pauses on the Show method and only code within the form can
execute. You cannot access the worksheet or command bars while the form is
visible. When the form is hidden or unloaded, code resume execution on the
line following the Show method.

When a form is displayed modelessly, with code like

UserForm1.Show vbModeless

the Show method causes the form to be displayed but execution carries on
after the Show even while the form is visible. If you don't specifiy vbModal
or vbModeless, the default mode is based on the ShowModal property of the
form.

I would explicitly use vbModal to ensure that the form is being displayed
modally.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Nigel" wrote in message
...
Hi All
I currently have an application code that uses a series of MsgBox to ask
user to accept or not specific actions. Such as "Data for Dec07 is
already loaded, overwrite?", a Yes / No option then determines the next
step.
This works ok.

I have now decided to incorporate a UserForm, with labels acting as
messages and command buttons to decide actions. Unlike the MsgBox which
halts the code this method does not pause. Rather than have to
re-engineer the entire code, I was looking for suggestions as to how to
proceed.


--

Regards,
Nigel





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Pausing Code

Thanks Chip, your suggestion which is proposing simulating a MsgBox using a
custom UserForm. Which is OK, but what I am trying to do is Open a
UserForm, keep it open, and have a message centre updating users on
progress, halting the code when an interaction is required, enabling some
controls for the user to interact with for the code to either progress or
cancel.

I think I will need to change control of the code to the UserForm and create
a series of subroutines / functions to execute the tasks, I am just going to
have to bite the bullet and being re-engineering.

Many thanks for your guidance.

--

Regards,
Nigel




"Chip Pearson" wrote in message
...
Nigel,

A user form can be displayed modally or modelessly. When it is displayed
modally, with code like

UserForm1.Show vbModal

the code pauses on the Show method and only code within the form can
execute. You cannot access the worksheet or command bars while the form is
visible. When the form is hidden or unloaded, code resume execution on the
line following the Show method.

When a form is displayed modelessly, with code like

UserForm1.Show vbModeless

the Show method causes the form to be displayed but execution carries on
after the Show even while the form is visible. If you don't specifiy
vbModal or vbModeless, the default mode is based on the ShowModal property
of the form.

I would explicitly use vbModal to ensure that the form is being displayed
modally.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Nigel" wrote in message
...
Hi All
I currently have an application code that uses a series of MsgBox to ask
user to accept or not specific actions. Such as "Data for Dec07 is
already loaded, overwrite?", a Yes / No option then determines the next
step.
This works ok.

I have now decided to incorporate a UserForm, with labels acting as
messages and command buttons to decide actions. Unlike the MsgBox which
halts the code this method does not pause. Rather than have to
re-engineer the entire code, I was looking for suggestions as to how to
proceed.


--

Regards,
Nigel






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Pausing Code

On Jan 3, 2:00 am, "Nigel" wrote:
Thanks Chip, your suggestion which is proposing simulating a MsgBox using a
custom UserForm. Which is OK, but what I am trying to do is Open a
UserForm, keep it open, and have a message centre updating users on
progress, halting the code when an interaction is required, enabling some
controls for the user to interact with for the code to either progress or
cancel.

I think I will need to change control of the code to the UserForm and create
a series of subroutines / functions to execute the tasks, I am just going to
have to bite the bullet and being re-engineering.

Many thanks for your guidance.

--

Regards,
Nigel


"Chip Pearson" wrote in message

...

Nigel,


A user form can be displayed modally or modelessly. When it is displayed
modally, with code like


UserForm1.Show vbModal


the code pauses on the Show method and only code within the form can
execute. You cannot access the worksheet or command bars while the form is
visible. When the form is hidden or unloaded, code resume execution on the
line following the Show method.


When a form is displayed modelessly, with code like


UserForm1.Show vbModeless


the Show method causes the form to be displayed but execution carries on
after the Show even while the form is visible. If you don't specifiy
vbModal or vbModeless, the default mode is based on the ShowModal property
of the form.


I would explicitly use vbModal to ensure that the form is being displayed
modally.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Nigel" wrote in message
...
Hi All
I currently have an application code that uses a series of MsgBox to ask
user to accept or not specific actions. Such as "Data for Dec07 is
already loaded, overwrite?", a Yes / No option then determines the next
step.
This works ok.


I have now decided to incorporate a UserForm, with labels acting as
messages and command buttons to decide actions. Unlike the MsgBox which
halts the code this method does not pause. Rather than have to
re-engineer the entire code, I was looking for suggestions as to how to
proceed.


--


Regards,
Nigel


Nigel,

To follow up on Chip's advice. I'm more of a hacker rather than a
programmer because I code to create interfaces for mathematical
modeling. But I do something similar to what you are thinking by
creating an interface form and showing it modally. But then conduct
the background work by setting Application.ScreenUpdating = False
after presenting to form to the user. So it looks modal even though
it isn't. And even with screen updating off, form objects will
continue to update based on events happening in background. So you
can show/hide, activate/deactivate various controls as needed until
the activity sequence is completed. So that's one way to do it.

Good Luck,

SteveM
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pausing Macro Patches New Users to Excel 2 March 28th 07 03:00 AM
Is there a way of pausing a macro Shazza Excel Discussion (Misc queries) 2 March 12th 07 10:59 PM
Pausing code execution until calculation is complete AVR Excel Programming 4 January 29th 07 05:29 PM
VBA: Pausing Code Execution Michael Loganov Excel Programming 2 September 14th 03 10:53 AM
Pausing code execution Rohit Thomas Excel Programming 1 July 9th 03 10:58 PM


All times are GMT +1. The time now is 01:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"