Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to add a macro to Outlook 2007 that asks me when I shut it down if I want to turn the Out of Office Assistant on, and then asks me when I open Outlook if I want to turn Out of Office Assistant off. I've found instructions for creating the prompt at close (at Outlook 2010: How to turn Out of Office automatically on when the Outlook is closed? and http://itknowledgeexchange.techtarget.com/itanswers/automating-out-of-office/) but I don't know how to write a macro for the prompt at open.

share|improve this question

1 Answer 1

See here http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/A_3487-Automating-Out-of-Office-in-Outlook.html

Private Sub Application_Quit()
    OutOfOffice True
End Sub

This is the part you are interested in.

Private Sub Application_Startup()
    OutOfOffice False
End Sub

Sub OutOfOffice(bolState As Boolean)
Const PR_OOF_STATE = "http://schemas.microsoft.com/mapi/proptag/0x661D000B"
Dim olkIS As Outlook.Store, olkPA As Outlook.PropertyAccessor
For Each olkIS In Session.Stores
    If olkIS.ExchangeStoreType = olPrimaryExchangeMailbox Then
        Set olkPA = olkIS.PropertyAccessor
        olkPA.SetProperty PR_OOF_STATE, bolState
    End If
Next
Set olkIS = Nothing
Set olkPA = Nothing
End Sub 

There is a note "not tested the code with Outlook 2010."

As well " CDO (Collaboration Data Objects) must be installed on the computer. If you discover that CDO is not installed, then you can download it from this Microsoft page."

http://www.microsoft.com/downloads/details.aspx?familyid=2714320d-c997-4de1-986f-24f081725d36&displaylang=en

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.