Welcome to Office Zealot Sign in | Join | Help

Tiling The Reply Message For Easy Reference

NOTE:
Due to data loss with OfficeZealot's blog server, all comments posted between April 28 and June 8 , 2005 to any of my blog entries were inadvertently deleted.  The end of this blog entry contains the text of the comments applicable to this posting that I was able to recover.

UPDATED Oct. 26, 2004
(As per Ryan's helpful suggestion below, I've added another procedure; updates appended to the end of this blog post)

Have you ever tried responding to a very long e-mail, and you find yourself either ALT-Tabbing back to the original, or scrolling down in your reply message to constantly refer to certain parts of the text? Sure, you can find the original message, open it and tile that window with your reply window horizontally/vertically. But we want a one-click solution! So here's some VBA and Win32 API code to do just that. This macro is meant to be run with your e-mail reply already open, and it assumes the message you are replying to is selected in your main Outlook window. Put this code into a new module in your Outlook VBA project, and associate it with a button on your new message form:

Option Explicit
Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Public Const SPI_GETWORKAREA = 48

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long

Sub ShowReplyMessage()
On Error GoTo EH:

    Dim objReply As Inspector
    Dim objMessage As Object
    Dim objMessageI As Inspector
    Dim lRet As Long
    Dim apiRECT As RECT       

    If ActiveExplorer.Selection.Count > 1 Then Exit Sub   

    Set objMessage = ActiveExplorer.Selection.Item(1)
    Set objReply = Application.ActiveInspector
    Set objMessageI = objMessage.GetInspector 

    objMessage.Display
    objMessageI.WindowState = olNormalWindow

    lRet = SystemParametersInfo(SPI_GETWORKAREA, vbNull, apiRECT, 0)   

    If lRet Then
        objMessageI.Top = 0
        objMessageI.Left = 0
        objMessageI.Height = (apiRECT.Bottom - apiRECT.Top) / 2
        objMessageI.Width = apiRECT.Right - apiRECT.Left

        objReply.Display
        objReply.WindowState = olNormalWindow
        objReply.Top = (apiRECT.Bottom - apiRECT.Top) / 2
        objReply.Left = 0
        objReply.Height = (apiRECT.Bottom - apiRECT.Top) / 2
        objReply.Width = apiRECT.Right - apiRECT.Left
    End If

Leaving:
    Set objMessage = Nothing
    Set objMessageI = Nothing
    Set objReply = Nothing

EH:
    If Err.Number <> 0 Then
        MsgBox "Something wrong has happened!", vbOKOnly + vbExclamation, "UNKNOWN ERROR"
        Err.Clear
        GoTo Leaving:
    End If
End Sub

Update:

This alternate procedure does not depend on you having your reply e-mail already open.  This macro is suitable to be called from your main Outlook window.  Just select the original e-mail in the folder and run the macro - it will open up the original message, and automatically create your reply message and tile both windows for you.  If you use just this procedure, make sure to add the same module level declarations as above:

Sub ReplyAndShowReferringMessage()
On Error Resume Next

    Dim objReply As Object
    Dim objReplyI As Inspector
    Dim objMessage As Object
    Dim objMessageI As Inspector
       
    If ActiveExplorer.Selection.Count > 1 Then Exit Sub
   
    Set objMessage = ActiveExplorer.Selection.Item(1)
    Set objReply = ActiveExplorer.Selection.Item(1).Reply
   
    objMessage.Display
    Set objMessageI = objMessage.GetInspector
    objMessageI.WindowState = olNormalWindow
    'H: 723 L: -4 T: -4 W: 1032
    Dim lRet As Long
    Dim apiRECT As RECT
   
    lRet = SystemParametersInfo(SPI_GETWORKAREA, vbNull, apiRECT, 0)
   
    If lRet Then
        objMessageI.Top = 0
        objMessageI.Left = 0
        objMessageI.Height = (apiRECT.Bottom - apiRECT.Top) / 2
        objMessageI.Width = apiRECT.Right - apiRECT.Left
       
        objReply.Display
        Set objReplyI = objReply.GetInspector
        objReplyI.WindowState = olNormalWindow
        objReplyI.Top = (apiRECT.Bottom - apiRECT.Top) / 2
        objReplyI.Left = 0
        objReplyI.Height = (apiRECT.Bottom - apiRECT.Top) / 2
        objReplyI.Width = apiRECT.Right - apiRECT.Left
    Else
        'DO NOTHING; Call to SystemParametersInfo failed
    End If
   
    Set objReply = Nothing
    Set objReplyI = Nothing
    Set objMessage = Nothing
    Set objMessageI = Nothing
End Sub

----------------------------------------------------------------
COMMENTS RESTORED FROM BACKUP:

Mon 6/6/2005 8:32 PM  Jimmy

How can I rename the button ... as of now it reads Project1.ReplyAndShowReferringMessage ... It takes up a quarter of my toolbar. Any help would be much appreciated.

Mon 6/6/2005 8:44 PM  Jimmy

The piece of code below vertically aligns the two windows:

    If lRet Then
        objMessageI.Top = 0
        objMessageI.Left = (apiRECT.Right - apiRECT.Left) / 2
        objMessageI.Height = apiRECT.Bottom - apiRECT.Top
        objMessageI.Width = (apiRECT.Right - apiRECT.Left) / 2
       
        objReply.Display
        Set objReplyI = objReply.GetInspector
        objReplyI.WindowState = olNormalWindow
       
        objReplyI.Top = 0
        objReplyI.Left = 0
        objReplyI.Height = apiRECT.Bottom - apiRECT.Top
        objReplyI.Width = (apiRECT.Right - apiRECT.Left) / 2
    Else

END COMMENTS RESTORE
----------------------------------------------------------------

Published Monday, January 19, 2004 11:34 PM by legault
Filed under:

Comments

#

Eric, This is a great bit of code and a feature many folks wish OL included natively. I have a couple of ideas for it... Why not change the two emails to be tile vertically rather than horizontally? Also, why not restore the original window settings for the email upon close?
Monday, January 26, 2004 1:31 PM by anderson

#

Good ideas! I'll try to find some time to work on your suggestions and update the blog.
Monday, January 26, 2004 2:13 PM by Anonymous

#

Looking forward to it
Tuesday, January 27, 2004 10:52 AM by anderson

# re: Tiling The Reply Message For Easy Reference

How can I add the code to perform the reply also.
Email item is selected. I click "MyReply".
Macro opens reply window for me. etc....

Thanks.
Monday, October 25, 2004 12:00 PM by Anonymous

# re: Tiling The Reply Message For Easy Reference

Ryan: good idea! I'll update my blog entry to add an alternate procedure to do just that.
Tuesday, October 26, 2004 10:24 AM by legault

# re: Tiling The Reply Message For Easy Reference

Jimmy: (sorry for the delay in replying, I was on vacation) To rename the custom toolbar button that points to the macro, enter Customize mode, right-click the button and change the value in the Name text box.
Monday, July 04, 2005 9:37 AM by legault
Anonymous comments are disabled