How to ge MsgBoxes to appear in the centre of a UserForm

Using Window 7 Home (64bit) - Excel 365.

I have an application that is run from a UserForm - is there some way that I can get MsgBoxes to appear in the centre of the UserForm?

Thanks,
Roy
RzzBAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Try this little demo.
28853719.xlsm

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Zac HarrisSystems Administrator Commented:
You can use this code to position the box in the user form. You may have to tweak the numbers of course for your form...

With UserForm1
    .StartUpPosition = 0
    .Top = 100
    .Left = 25
    .Show
End With

Open in new window

RzzBAuthor Commented:
Brilliant - Works a treat.
Many thanks.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest youincluding these two new ones.
An Experts Exchange Shortcut for the Truly Lazy (for Apple OS X)
A Guide to Writing Understandable and Maintainable VBA Code
Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014
RzzBAuthor Commented:
Ooopsss - Spoke too soon - slight problem.

It works fine with the first Message box that is opened - opened perfectly in the centre of my UsreForm.

After this, further invocations of MsgboxEX, go to the top left of the monitor.

I must be doing something wrong?

Thoughts?
Roy
Martin LissOlder than dirtCommented:
Do you have a project that you can zip up and attach and also describe the steps that resulted in the problem?
RzzBAuthor Commented:
OK, after much hair pulling, this seems to be associated with the fact that I'm running my application without any worksheets visible. For how/why see this thread...

Complications - Interactions with other WorkBooks

The attached is a small demo of the strange behaviour. It works fine with the application hidden on the first invocation - but on subsequent invocations the message box appears at the top right. This is on my single monitor set up.

On my multi screen set up it hangs on the second invocation.

Thanks for your help,
Roy
MsgboxExTest.xlsm
Martin LissOlder than dirtCommented:
Please describe step by step what to do to reproduce the problem because I don't seem to be able to reproduce it via Excel 2010.
RzzBAuthor Commented:
Here is a small video, on dropbox, showing what's going on.

BTW - When you run this test don't have any other excel workbooks running.
RzzBAuthor Commented:
One further thing I have just found is that if you don't move the userform after you open it, then it goes to the TopLeft on first invocation.
RzzBAuthor Commented:
One further thing I have just found is that if you don't move the userform after you open it, then it goes to the TopLeft on first invocation.

Hmmm - on further investigation - only sometimes ....
Martin LissOlder than dirtCommented:
Sorry but I still can't reproduce the problem and you might want to post a new question to get more attention. If you do you should note the the link you posted to your dropbox is missing the required colon following https.
RzzBAuthor Commented:
Opps yes - the link should be...

https://www.dropbox.com/sh/6d58e8bakvtm70r/AABrhO_CnzsxfXK4_ltb0aVpa?dl=0

OK - Perhaps it's a 365 problem?

So do I do a completely new post, or do I somehow do it in this post but not as a comment?
Martin LissOlder than dirtCommented:
I would open a new question explaining the problem, refer to this question and include the video.
RzzBAuthor Commented:
Just for clarity - did you run the test workbook that I posted - and it worked correctly when using Excel 2010 - what Windows version are you using?
Martin LissOlder than dirtCommented:
I used your test file in Excel 2010 in Windows XP running as a VM on an iMac (not exactly typical), and yes as far as I can tell it works correctly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.