logo
search
Others

How to Set Microsoft 365 Outlook Automatic Replies via Excel VBA

John WilsonJohn Wilson Oct 15, 2026 868 views

Question details

The user wants to programmatically configure Microsoft 365 Outlook automatic replies (Out of Office) using VBA code executed from an Excel workbook.

How to Set Microsoft 365 Outlook Automatic Replies via Excel VBA
Product
Microsoft Excel and Microsoft Outlook
Device & OS
not provided
Scenario
Automating email out-of-office or auto-reply settings programmatically through a spreadsheet interface.
Observed behavior
The user is seeking the correct VBA methods and object models to establish a connection between Excel and Outlook to toggle automatic replies effectively.
Before you start

Ensure you have the classic Microsoft Outlook desktop client installed and set up with an Exchange account, as the 'New Outlook' and web versions do not fully support VBA COM automation.

Solution 1Recommended

Use the Outlook Object Model via Excel VBA

Connect Excel to the classic Outlook desktop application using VBA to manage out-of-office settings via the PropertyAccessor interface.

Automating Outlook from Excel requires referencing the Outlook Object Library. Modifying out-of-office settings programmatically applies primarily to Exchange accounts.

You will need to access the PR_OOF_STATE property using the Outlook PropertyAccessor to toggle the automatic replies.

1
Open the VBA Editor in Excel

Open your Excel workbook and press ALT + F11 to launch the Visual Basic for Applications (VBA) Editor.

2
Enable the Outlook Object Library

In the VBA Editor menu, navigate to Tools > References. Scroll down the list, check the box next to 'Microsoft Outlook Object Library', and click OK.

3
Write the Automation Script

Insert a new module and write a macro that creates an Outlook Application instance (e.g., Set outApp = CreateObject("Outlook.Application")).

4
Modify the OOF State Property

Use the ExchangeUser object and its PropertyAccessor interface to target the PR_OOF_STATE property schema and set it to True to enable the automatic replies.

Use the Outlook Object Model via Excel VBA
Version Compatibility Limitation: The 'New Outlook' application currently does not support COM automation. This VBA method will only work successfully with the classic Outlook desktop client.
Free Microsoft Office alternative

Experience Seamless Spreadsheet Management with WPS Office

While automating Microsoft 365 Outlook requires specific Microsoft COM dependencies, WPS Office offers a powerful, lightweight alternative for all your spreadsheet processing and data management needs. Enjoy a robust office suite without the hefty subscription fees.

  1. 1. Download the software: Visit the official WPS Office website to download the free installation package for your operating system.
  2. 2. Install WPS Office: Run the downloaded installer and follow the quick on-screen instructions to set up the office suite on your device.
  3. 3. Open your existing spreadsheets: Launch WPS Spreadsheets, click 'Open', and select your existing Microsoft Excel workbooks to resume your work instantly.
Highly compatible with Microsoft Excel (.xlsx, .xls) and standard macro workflows.Lightweight architecture ensures fast performance on both older and newer devices.Built-in support for advanced formulas, pivot tables, and data analysis tools.Free to download and use for your everyday personal and business tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Can I automate the 'New Outlook' for Windows using Excel VBA?

No, the 'New Outlook' app is based on web technologies and currently does not support the COM (Component Object Model) add-ins or VBA automation used by the classic Outlook desktop client.

Why am I getting an 'ActiveX component can't create object' error in VBA?

This error typically occurs if the classic Outlook application is not installed on your machine, or if you are running the 'New Outlook' version. Ensure the classic desktop version of Outlook is installed and set as the default email client.

Do I need an Exchange account to set automatic replies via VBA?

Yes, the Out of Office (OOF) settings accessed through Outlook's PropertyAccessor in VBA are generally tied to Microsoft Exchange Server environments. Standard IMAP or POP3 accounts do not natively support server-side automatic replies through this exact method.