Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Userform label not visible...sometimes=> force it to be drawn?

Status
Not open for further replies.

Gavona

Technical User
Aug 27, 2002
1,771
GB
in the Immediate window I enter: userform1.show vbmodeless
and the userform is displayed complete with its label, as expected.

On the other hand when I have the same command in my procedure the Userform displays but the label is not visible.

If I watch the expression userform1.Visible the problem persists but if I set the watch to "Break when value changes" the label displays with the userform.

So it seems like I need to do something to encourage Excel to draw the label before the next bit of code operates.

Not sure if this is relevant but my initialise code is:
Code:
Private Sub UserForm_Initialize()

GoTo skipped 'is this stopping display of label?
If ActiveSheet.Cells(1.1).Value = 1 Then
    Me.Controls("SubtotalsWarning").Caption = "Preparing sheet for first use - this could take a while :(" & Chr(10) & "You are advised to save the workbook after the process has finished so that it is ready for use when you next open it. "
Else
    Me.Controls("SubtotalsWarning").Caption = "Adding or Removing Sub-totals - This may take a few minutes as you have a large worksheet."
End If
skipped:
  Me.startupposition = 0
  Me.Top = 100
  Me.Left = Application.Left + 50
End Sub

Gavin
 
What happens if you comment the 2 lines of code out?

Code:
[green]
'GoTo skipped [/green]
If ActiveSheet.Cells(1.1).Value = 1 Then
    Me.Controls("SubtotalsWarning").Caption = "Preparing sheet for first use - this could take a while :(" & Chr(10) & "You are advised to save the workbook after the process has finished so that it is ready for use when you next open it. "
Else
    Me.Controls("SubtotalsWarning").Caption = "Adding or Removing Sub-totals - This may take a few minutes as you have a large worksheet."
End If
[green]skipped:[/green]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Well I added them out in order to eliminate the code between as possible cause. So doesn't make any difference - still don't see the label.

Gavin
 
Narrowed it down - :

I change from
userform1.show vbmodeless
to
userform1.show 'vbmodeless
And the label displays on the form but I need the form modeless

So my calling code is
Application.screenupdating=true
userform1.show vbmodeless
application.wait.waittime
do stuff

With a wait time of .1 second the code now works as expected. But the form is supposed to warn that a process may take a while not add to the process time! I feel I must be missing something! As I said originally
Gavona said:
So it seems like I need to do something to encourage Excel to draw the label before the next bit of code operates.


Gavin
 
Solved [bigsmile]
userform1.show vbmodeless
Userform1.repaint

Shame it is not a single line of code but there you go!

Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top