How to Set Microsoft 365 Outlook Automatic Replies via Excel VBA
Question details
The user wants to programmatically configure Microsoft 365 Outlook automatic replies (Out of Office) using VBA code executed from an Excel workbook.

- 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.
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.
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.
Open your Excel workbook and press ALT + F11 to launch the Visual Basic for Applications (VBA) Editor.
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.
Insert a new module and write a macro that creates an Outlook Application instance (e.g., Set outApp = CreateObject("Outlook.Application")).
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.

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. Download the software: Visit the official WPS Office website to download the free installation package for your operating system.
- 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. Open your existing spreadsheets: Launch WPS Spreadsheets, click 'Open', and select your existing Microsoft Excel workbooks to resume your work instantly.

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.




