Outlook - UserForm open in center of New Email Window

harveya915

Board Regular
I added a button to the ribbon of a New Email Window that when clicked opens up a UserForm. I would like for that UserForm to open up on the center of that New Email Window. Below is the code that I have so far.
Code:
Sub Add_Client_ID()
Dim wdDoc As Object
Dim oRng As Object
Dim oBM As Object
Dim oFrm As UserForm1
Dim strText As String
    On Error GoTo Err_Handler
    If TypeName(ActiveWindow) = "Inspector" Then
        If ActiveInspector.IsWordMail And ActiveInspector.EditorType = olEditorWord Then
            Set wdDoc = ActiveInspector.WordEditor
            On Error Resume Next
            Set oBM = wdDoc.bookmarks("_MailAutoSig")
            If Not oBM Is Nothing Then
                Set oRng = oBM.Range
                oRng.Start = oRng.Start + 2
                oRng.collapse 1
            Else
                Set oRng = wdDoc.Range
                oRng.collapse 1
            End If
            On Error GoTo Err_Handler
            Set oFrm = New UserForm1
            With oFrm
                .Show
                If .Tag = 0 Then GoTo lbl_Exit
                strText = vbCr & "=================================================================" & " " & vbCr & _
                          "The following information is for HIA/GK internal use and can be ignored." & " " & vbCr & _
                          "File ID:_       " & .TextBox1.Text & vbCr & _
                          "Type_PL:_    " & .ComboBox1.Text & vbCr & _
                          "Type_CL:_    " & .ComboBox2.Text & vbCr & _
                          "Drawer:_     " & .ComboBox3.Text & vbCr & _
                          "POL:_           " & .TextBox2.Text & vbCr & _
                          "================================================================="
                Unload oFrm
            End With
            oRng.Text = strText
            oRng.Start = wdDoc.Range.Start
            oRng.collapse 1
            oRng.Select
        Else
            GoTo Err_Handler
        End If
    Else
        GoTo Err_Handler
    End If
lbl_Exit:
    Set wdDoc = Nothing
    Set oRng = Nothing
    Set oBM = Nothing
    Set oFrm = Nothing
    Exit Sub
Err_Handler:
    Beep
    Resume lbl_Exit
End Sub
 

wornhall

Board Regular
Word's document control yields the following when running through the menu ribbon "Layout, Orientation, Portrait":

Code:
Sub Macro3()
'
' Macro3 Macro
'
'
    Selection.WholeStory
    With ActiveDocument.Styles(wdStyleNormal).Font
        If .NameFarEast = .NameAscii Then
            .NameAscii = ""
        End If
        .NameFarEast = ""
    End With
    With ActiveDocument.PageSetup
        .LineNumbering.Active = False
        .Orientation = wdOrientPortrait
        .TopMargin = InchesToPoints(0.12)
        .BottomMargin = InchesToPoints(0.12)
        .LeftMargin = InchesToPoints(0.5)
        .RightMargin = InchesToPoints(0.5)
        .Gutter = InchesToPoints(0)
        .HeaderDistance = InchesToPoints(0.5)
        .FooterDistance = InchesToPoints(0.5)
        .PageWidth = InchesToPoints(8.5)
        .PageHeight = InchesToPoints(11)
        .FirstPageTray = wdPrinterDefaultBin
        .OtherPagesTray = wdPrinterDefaultBin
        .SectionStart = wdSectionNewPage
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .VerticalAlignment = wdAlignVerticalTop
        .SuppressEndnotes = False
        .MirrorMargins = False
        .TwoPagesOnOne = False
        .BookFoldPrinting = False
        .BookFoldRevPrinting = False
        .BookFoldPrintingSheets = 1
        .GutterPos = wdGutterPosLeft
    End With
End Sub
You can delete the code line that are irrelevant.
 

Some videos you may like

This Week's Hot Topics

  • Get External Data (long shot question!)
    This is likely a long shot but I am wondering if it is at all possible for Excel to somehow 'change' the contents of a URL that is being linked to...
  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • Cell Formatting
    Good Morning, I need to format a few different cells in the following manners: A1 has to always add a colon (:) after whatever is typed in by a...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • Workbook_Change stopped working !
    I am working on an app to speed up & automate processing of Credit Cards statements. After data is input from a CSV file, it is presented to the...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
Top