A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

forcing a rule when opening outlook via code



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 23rd 09, 01:38 PM posted to microsoft.public.outlook.program_vba
thomas donino
external usenet poster
 
Posts: 2
Default forcing a rule when opening outlook via code

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 ToolsRules 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
  #2  
Old November 23rd 09, 04:35 PM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default forcing a rule when opening outlook via code

Since the computer is on all night, have you considered rewriting your
code to work from Outlook, instead of Excel? You could rewrite the
rule as VBA.

--JP

On Nov 23, 8:38*am, thomas donino
wrote:
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 ToolsRules the rule
is unchecked. How can i force the rule i want to be checked when Outlook is
opened via this method?

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie- is this possible? (code to save attachments from server to network drive, without opening email locally) ker_01 Outlook and VBA 3 October 3rd 08 02:33 PM
Forcing Outlook to reply to all emails using HTML format Lollie Outlook - Calandaring 4 August 26th 08 02:34 PM
Forcing Send only - OUTLOOK Ludo Outlook and VBA 4 December 22nd 07 09:15 AM
Stop Outlook forcing area code on mobile numbers Jisher Outlook - Using Contacts 1 August 22nd 07 02:26 PM
FORCING RPC OVER HTTP-OUTLOOK 2003/2007 Dave Durand Outlook - Installation 1 May 12th 07 01:59 AM


All times are GMT +1. The time now is 12:29 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.