如何将 MS Outlook 2007 对话框从 MS Access 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
I am attempting to allow a user of a MS Access 2007 database to select another user from the MS Outlook GAL. I currently have working code that opens the Outlook Select Names Dialog, but it hides behind the database window until a user clicks on Outlook.
How do I make the dialog visible to the user in VBA?
Here's my code for the dialog (typos are a result of a manual copy--this code is on an airgapped network):
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过在
.SetDefaultDisplayMode olDefaultSingleName
之后添加以下行来完成这项工作:I made this work by adding the following line after
.SetDefaultDisplayMode olDefaultSingleName
:非常感谢兰德尔!我还发现,如果 Outlook 没有实际打开,则不起作用,因为 ActiveWindow 将为空,因此像这样将其包装起来也有帮助:
Thanks alot Randall! I've also found that if Outlook isn't actually opened that won't work because ActiveWindow will be null, so wrapping it up like this helps too: