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

G'day there again People,

I was just reading a thread here about modal/modeless forms. I'm
using Excel 2000, with a modal form that's not performing quite the way
I thought it would.

I have the following code in the ThisWorkBook object:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

If Me.Saved = False Then
Load exitFrm
exitFrm.Show

Me.Save

exitFrm.Hide
Unload exitFrm
End If

End Sub


exitFrm is a userform with no buttons, but says "Saving data...
please wait". It's very pretty with white letters on a red background
=).

When used modally, as expected, I have to close the form before
the Me.Save part works. However if I set modal to false, there is only a
blank userform shown. I have a title bar, a thick line around the form
and more white space than is healthy.

I've tried, without success, to install various counters in
different nooks and crannies to see if it just needed some thinking
space to draw the text. Now I've run out of ideas and I'm hoping someone
can see what I've done wrong.

Thanks once more
Ken McLennan
Qld, Australia
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Modal oddity

I'm not sure what caused it (windows or excel), but in win98/excel2002, I could
do this:

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)

If Me.Saved = False Then
Load exitfrm
exitfrm.Show False
DoEvents
'exitfrm.Repaint

Me.Save

exitfrm.Hide
Unload exitfrm
End If

End Sub

Both the DoEvents and .repaint made the userform appear ok.



Ken McLennan wrote:

G'day there again People,

I was just reading a thread here about modal/modeless forms. I'm
using Excel 2000, with a modal form that's not performing quite the way
I thought it would.

I have the following code in the ThisWorkBook object:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

If Me.Saved = False Then
Load exitFrm
exitFrm.Show

Me.Save

exitFrm.Hide
Unload exitFrm
End If

End Sub

exitFrm is a userform with no buttons, but says "Saving data...
please wait". It's very pretty with white letters on a red background
=).

When used modally, as expected, I have to close the form before
the Me.Save part works. However if I set modal to false, there is only a
blank userform shown. I have a title bar, a thick line around the form
and more white space than is healthy.

I've tried, without success, to install various counters in
different nooks and crannies to see if it just needed some thinking
space to draw the text. Now I've run out of ideas and I'm hoping someone
can see what I've done wrong.

Thanks once more
Ken McLennan
Qld, Australia


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Modal oddity

G'day there Dave,

I'm not sure what caused it (windows or excel), but in win98/excel2002, I could
do this:


It's a mystery to me, too.

-----[SNIP]-----

Both the DoEvents and .repaint made the userform appear ok.


Yes, you're quite correct. That made it run just as I wanted it
to. Thanks very much for that. I'd tried DoEvents with both modal and
non modal settings for the form, but I'd not thought of the .repaint
bit. That seems to have done the trick.

Of course, now that I've got that part correct (or perhaps, now
that YOU'VE got that part correct for me) it's running through that
section of code whether the workbook has been saved or not. I've only
just had time to try your code and confirm it. I've not yet tried to see
why it runs all the time, but I hope to check that out tonight. Even if
I can't fix it, I've no real problem with it running everytime anyway.

Thanks very much for taking the time to help. It's saved me hours
of confusion =).

See ya
Ken McLennan
Qld, Australia
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
Userform modal Dave K[_3_] Excel Discussion (Misc queries) 1 April 9th 10 07:41 AM
Mode - getting bi- and multi-modal results?? Jdolsak Excel Worksheet Functions 5 March 15th 06 12:04 AM
Forms that are modal in 97 are not modal in 2003 Old Car Excel Discussion (Misc queries) 1 April 27th 05 08:25 AM
Accessing selected cell from modal dialog Jim McLeod Excel Programming 2 April 22nd 04 03:47 PM
Modal User Form Jim M[_3_] Excel Programming 1 November 4th 03 10:38 PM


All times are GMT +1. The time now is 04:08 AM.

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"