如何从MS Access 2007将MS Outlook 2007对话框显示在最前面?

| 我试图允许MS Access 2007数据库的用户从MS Outlook GAL中选择另一个用户。我目前有工作代码可以打开Outlook“选择名称”对话框,但是它一直隐藏在数据库窗口后面,直到用户单击Outlook。 如何在VBA中使对话框对用户可见? 这是我的对话框代码(打字稿是手动复制的结果-该代码在空白的网络上):
set OLApp = CreateObject(\"Outlook.Application\")
set OLDialog = OLApp.Session.GetSelectNamesDialog
with OLDialog
    .SetDefaultDisplayMode olDefaultSingleName
    if .Display then
        if OLDialog.Recipients.Count then
            theUser = OLDialog.Recipients.Item(1)
        end if
    end if
end with
    
已邀请:
我通过在ѭ1after之后添加以下行来完成此工作:
OLApp.ActiveWindow.Activate
    
非常感谢Randall!我还发现,如果未真正打开Outlook,则将无法正常工作,因为ActiveWindow将为null,因此像这样将其包装起来也有帮助:
If Not (oApp.ActiveWindow Is Nothing) Then  \'only if there\'s a window
            oApp.ActiveWindow.Activate  \'make sure outlook comes to foreground first
End If
    

要回复问题请先登录注册