T
thomas donino
The code below runs in an Excel workbook open event. It does so to retrieve
the attachments excel needs from the nightly emails. The rule i have set up
in Outlook is always unchecked when Excel opens outlook so I put in a line of
code to force the rule. it executes the show progress of the rule but nnoe of
what the rule is supposed to do is done AND when i go to Tools>Rules the rule
is unchecked. How can i force the rule i want to be checked when Outlook is
opened via this method?
Sub DoThisonOpen()
Dim objApp As Outlook.Application
Dim objNS As Namespace
Dim objCurrInbox As MAPIFolder, objExplorer As Object
On Error Resume Next
'close outlook if its already open, so I can reopen and do
send/receive all
Set objApp = GetObject(, "Outlook.Application")
If Err.Number = 429 Then
Err.Number = 0
Set objApp = New Outlook.Application
Else
objApp.Quit
Sleep 3000
Set objApp = New Outlook.Application
End If
Set objNS = objApp.GetNamespace("MAPI")
Set objCurrInbox = objNS.GetDefaultFolder(olFolderInbox)
objCurrInbox.Display
Set objExplorer = objCurrInbox.GetExplorer
objExplorer.Activate
objExplorer.CommandBars("Standard").Controls("Send/Re&ceive").Execute
Sleep 30000
' code to make the rule active
objApp.Session.DefaultStore.GetRules.Item("xtrader export").Execute
ShowProgress:=True
Sleep 30000
'reset the variables
Set objNS = Nothing
Set objCurrInbox = Nothing
Set objExplorer = Nothing
'close outlook
objApp.Quit
Set objApp = Nothing
End Sub
the attachments excel needs from the nightly emails. The rule i have set up
in Outlook is always unchecked when Excel opens outlook so I put in a line of
code to force the rule. it executes the show progress of the rule but nnoe of
what the rule is supposed to do is done AND when i go to Tools>Rules the rule
is unchecked. How can i force the rule i want to be checked when Outlook is
opened via this method?
Sub DoThisonOpen()
Dim objApp As Outlook.Application
Dim objNS As Namespace
Dim objCurrInbox As MAPIFolder, objExplorer As Object
On Error Resume Next
'close outlook if its already open, so I can reopen and do
send/receive all
Set objApp = GetObject(, "Outlook.Application")
If Err.Number = 429 Then
Err.Number = 0
Set objApp = New Outlook.Application
Else
objApp.Quit
Sleep 3000
Set objApp = New Outlook.Application
End If
Set objNS = objApp.GetNamespace("MAPI")
Set objCurrInbox = objNS.GetDefaultFolder(olFolderInbox)
objCurrInbox.Display
Set objExplorer = objCurrInbox.GetExplorer
objExplorer.Activate
objExplorer.CommandBars("Standard").Controls("Send/Re&ceive").Execute
Sleep 30000
' code to make the rule active
objApp.Session.DefaultStore.GetRules.Item("xtrader export").Execute
ShowProgress:=True
Sleep 30000
'reset the variables
Set objNS = Nothing
Set objCurrInbox = Nothing
Set objExplorer = Nothing
'close outlook
objApp.Quit
Set objApp = Nothing
End Sub