PDA

View Full Version : Userform does not show when I tell it to! Bad UserForm!!!



samuelwright
12-09-2005, 04:21 AM
Helloo!!

I apologise for moving this problem into a new post, but is was moving along a different direction than the original problem I had in an old post:

I am having a problem in viewing a userform when I click a button that has been added to a New Message Toolbar

The facts are:

1. Word 2003 is selected as the default message editor.
2. When Outlook starts, some VBA posts a new button onto the New Message toolbar.
3. This new button is programmed to load and show a userform which outputs a string into the Subject Line of the message.

Here is the problem:

1. When I click the button, the form loads, but it does not show in front of the New Message, but behind it (ie in terms of window layers it goes Outlook Inbox-UserForm-New Message!)

I dont want to have to minimise the New Message window to show the UserForm. Is there any way of bringing the Userform to the front? I have tried putting a userform.visible in the Initialize event, and in the class module but to no avail. I attach the VBA Project below.

PS this is not a problem when Word is not the default message editor...

PPS a lot of this code is from an excellent KB entry by MOS MASTER...a wonderful person and probably an actual genius:clap: check it here:

http://www.vbaexpress.com/kb/getarticle.php?kb_id=502

fumei
12-20-2005, 10:09 AM
I downloaded - quite similarly to the othe post, but am unable to read these files either. So I can't look at them. Therefore it is difficult to make much in the way of useful comments.

However, what is the order of creation? Is the userform displayed before the new message, or after?

matthewspatrick
12-20-2005, 11:44 AM
Could you please export the individual modules and userforms? I do not want to mess up my own VBAProject.otm by trying an import :devil:

Killian
12-20-2005, 05:50 PM
Just speculating... the modal userform takes the focus of the Outlook app when it is shown as expected - but the mail message is external to that app since it is an instance of Word when Word is used as the mail editor.

samuelwright
01-03-2006, 01:57 AM
Hi all, happy new year! :hi:

Sorry have not got back earlier, been away for crimbo!

Gerry: the order goes

1. When new message (or reply/forward) is opened in Outlook, VBAProject puts a new button on taskbar
2. This button, when clicked, opens a userform, with fields to write to subject line etc
Therefore, new message is opened first, then userform

Killian

Yes you are right, I think. I have tried the following bit of code, which does not solve the problem in the way I want, but it kind of removes the symptoms if Word is the editor...ish


If ActiveInspector.IsWordMail = True Then _
Application.ActiveInspector.WindowState = olMinimized
SubjectNameForm.Show
Exit Sub

If ActiveInspector.IsWordMail = False Then
SubjectNameForm.Show
End If


The message window is then maximised again once the userform is completed. Probably not the greatest work of VBA you will ever see :blush

Killian
01-03-2006, 05:03 AM
The message window is then maximised again once the userform is completed. Probably not the greatest work of VBA you will ever see :blushSeems like a perfectly valid solution to me...

Carmi
05-15-2006, 03:57 AM
Hi all - just wondering if there is any further progression with this thread. I m having similar problem as I have posted under

http://www.vbaexpress.com/forum/showthread.php?t=7989

The work around code that Sam developed does not seem to work if there are other instances of word open

Hoping for a solution : pray2:

Carmi
05-18-2006, 02:48 AM
The follwing post maybe of help as now solved

http://www.vbaexpress.com/forum/showthread.php?t=7989