Consulting

Results 1 to 8 of 8

Thread: Userform does not show when I tell it to! Bad UserForm!!!

  1. #1

    Userform does not show when I tell it to! Bad UserForm!!!

    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 check it here:

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

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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?

  3. #3
    VBAX Expert
    Joined
    Jul 2004
    Location
    Wilmington, DE
    Posts
    600
    Location
    Could you please export the individual modules and userforms? I do not want to mess up my own VBAProject.otm by trying an import

  4. #4
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    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.
    K :-)

  5. #5
    Hi all, happy new year!

    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

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

    If ActiveInspector.IsWordMail = False Then
    SubjectNameForm.Show
    End If
    [/VBA]

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

  6. #6
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Quote Originally Posted by samuelwright
    The message window is then maximised again once the userform is completed. Probably not the greatest work of VBA you will ever see
    Seems like a perfectly valid solution to me...
    K :-)

  7. #7
    VBAX Regular
    Joined
    Apr 2006
    Posts
    8
    Location
    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

  8. #8
    VBAX Regular
    Joined
    Apr 2006
    Posts
    8
    Location
    The follwing post maybe of help as now solved

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •