简体   繁体   English

如何通过从 MS Word VBA 用户窗体运行的 VBA(宏)将 Outlook 设置为脱机工作模式

[英]How to Set Outlook in Work Offline Mode by VBA(Macro) Running From MS Word VBA UserForm

I am trying to run a VBA code which it's supposed to let the user attach a file into a Mail Merge function.我正在尝试运行一个 VBA 代码,它应该让用户将文件附加到邮件合并功能中。

In order to do this I need to put Outlook in Offline mode to keep the mails in outbox before attaching any files to mails.为了做到这一点,我需要将 Outlook 置于离线模式,以便在将任何文件附加到邮件之前将邮件保存在发件箱中。 Now I would like to know if there is a method to put Outlook 2007 in Offline mode from a Word Macro?现在我想知道是否有一种方法可以通过 Word 宏将 Outlook 2007 置于脱机模式?

First, add a reference to the Outlook Object Library.首先,添加对 Outlook 对象库的引用。 If Outlook will already be open:如果 Outlook 已经打开:

Outlook.ActiveExplorer().CommandBars.FindControl(, 5613).Execute

if Outlook is closed:如果 Outlook 已关闭:

Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
olApp.GetNamespace("MAPI").Folders.GetFirst.GetExplorer.CommandBars.FindControl(, 5613).Execute

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM