跳至主要内容

如何在启动Outlook时自动打开多个Outlook窗口? 

Author: Xiaoyang Last Modified: 2025-05-07

当您启动Outlook账号时,邮件窗口会正常打开。是否可以在启动Outlook的同时自动打开其他Outlook窗口,例如邮件、日历、联系人和任务窗口?

使用VBA代码在启动Outlook时自动打开多个Outlook窗口


使用VBA代码在启动Outlook时自动打开多个Outlook窗口

在这里,我可以介绍一个VBA代码,帮助您在启动Outlook时立即打开多个Outlook窗口,例如邮件、日历、联系人和任务窗口。请按照以下步骤操作:

1. 按住 ALT + F11 键打开 Microsoft Visual Basic for Applications 窗口。

2. 在 Microsoft Visual Basic for Applications 窗口中,双击 Project1(VbaProject.OTM) 窗格中的 ThisOutlookSession 以打开模块,然后将以下代码复制并粘贴到空白模块中。

VBA代码:在启动Outlook时自动打开多个Outlook窗口:

Private Sub Application_Startup()
Dim xCalendar As Folder
Dim xTasks As Folder
Dim xContacts As Folder
Dim xInbox As Folder
Dim xExplorer As Outlook.Explorer
Dim xWidth, xHeight As Integer
On Error Resume Next
xWidth = Int(GetSystemMetrics32(0) / 4) + 60
xHeight = GetSystemMetrics32(1)
Set xInbox = Outlook.Application.ActiveExplorer.CurrentFolder
xInbox.Display
Set Application.ActiveExplorer.CurrentFolder = xInbox
Set xExplorer = Application.ActiveExplorer
With xExplorer
    .WindowState = olNormalWindow
    .Top = 0
    .Left = 0
    .Height = xHeight
    .Width = xWidth
End With
Set xCalendar = Outlook.Session.GetDefaultFolder(olFolderCalendar)
xCalendar.Display
Set xExplorer = Application.ActiveExplorer
With xExplorer
    .WindowState = olNormalWindow
    .Top = 0
   .Left = xWidth
    .Height = xHeight
    .Width = xWidth
End With
Set xContacts = Outlook.Session.GetDefaultFolder(olFolderContacts)
xContacts.Display
Set xExplorer = Application.ActiveExplorer
With xExplorer
    .WindowState = olNormalWindow
    .Top = 0
    .Left = xWidth * 2
    .Height = xHeight
    .Width = xWidth
End With
Set xTasks = Outlook.Session.GetDefaultFolder(olFolderTasks)
xTasks.Display
Set xExplorer = Application.ActiveExplorer
With xExplorer
    .WindowState = olNormalWindow
    .Top = 0
    .Left = xWidth * 3
    .Height = xHeight
    .Width = xWidth
End With
End Sub
doc open multiple windows startup 1

3. 接着继续点击 插入 > 模块,将下面的代码复制并粘贴到打开的空白模块中,参见截图:

Declare Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" (ByVal xIndex As Long) As Long
doc open multiple windows startup 2

4. 然后保存并关闭代码,重新启动Outlook以使代码生效。现在,当打开Outlook时,邮件、日历、联系人和任务窗口将会自动并排打开,参见截图:

doc open multiple windows startup 3