我想在 Outlook 2007 中新增一個巨集,在關閉 Outlook 時詢問我是否要開啟“外出助手”,然後在開啟 Outlook 時詢問我是否要關閉“外出助理”。我找到了在關閉時創建提示的說明(位於Outlook 2010:如何在 Outlook 關閉時自動開啟「離開辦公室」?和http://itknowledgeexchange.techtarget.com/itanswers/automating-out-of-office/)但我不知道如何為開啟時的提示編寫巨集。
答案1
Private Sub Application_Quit()
OutOfOffice True
End Sub
這是您感興趣的部分。
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
有一條註解「未使用 Outlook 2010 測試程式碼」。
另外,“電腦上必須安裝 CDO(協作資料物件)。如果您發現未安裝 CDO,則可以從此 Microsoft 頁面下載它。”