How to set the start position of a modeless user-form?

Davavo

Board Regular
Joined
Aug 3, 2019
Messages
82
Hello all.

I know how to position a modal form, but a modeless form, acting as a 'please wait' sign is not responding in the same way.
If anyone can help I would be very grateful.

I position a regular form with the following private sub in the forms code window

Code:
Private Sub UserForm_Activate()

    Dim TopOffset As Integer
    Dim LeftOffset As Integer
    
    TopOffset = (Application.UsableHeight / 2) - (Me.Height / 2)
    LeftOffset = (Application.UsableWidth / 2) - (Me.width / 2)
    
    Me.Top = Application.Top + TopOffset
    Me.Left = Application.Left + LeftOffset


End Sub

I call this code from a public sub

Code:
Sub CallUserForm1()

Load UserForm1


UserForm1.Show


End Sub

I have several of these, all working fine.

The modeless form is exactly the same except adding 'false' to indicate modeless
Code:
userform1.show false

This causes the code in the forms window, that positions the form, to be ignored.

is there a work around?

Thanks in advance.

D
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
It works fine for me. Is it the first time that form has been loaded and shown?
 
Upvote 0
Hi, thanks for your reply.
no, i have such down and restarted excel overnight.
Strange

one of these messing with it?

Code:
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
 
Last edited:
Upvote 0
Doevents solved it.

Also changed 'False' to vbmodeless but thats just to be more descriptive.

Code:
Sub CallUserForm9()

Load UserForm9


UserForm9.Show vbModeless
DoEvents


End Sub


Thanks for your help RoryA!
 
Last edited:
Upvote 0
Screenupdating is probably the culprit.
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,135
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top