View Single Post
  #16  
Old March 9th 06, 01:02 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Message Rule Does Not Run VBA Procedure

It's always in the same location, in your Windows profile folders. You won't see it if you don't have hidden/system items turned on.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Lowell" wrote in message ...
You want to know what's weird? After I renamed the original Vbaproject.otm
and got everything working again, there is not a new Vbaproject.otm in the
same folder as the one I renamed. I haven't found it (the new one) yet. Is
there a set location where this file is stored?

"Sue Mosher [MVP-Outlook]" wrote:

The file *is* named vbaproject.otm. The project name doesn't matter.



"Lowell" wrote in message ...
Sue - That worked. However, instead of having VBAProject.OTM in the Project
Explorer pane of VB Editor, I now have an item named Project 1. Should I
rename it to VBAProject.OTM?

"Sue Mosher [MVP-Outlook]" wrote:

My experience is that the VBAProject.OTM file can be a little fragile, especially if you're using "run a script" rules. The way to back up your modules is to export them.

You could try changing the security setting to Low to see if that helps the file recovery, but I fear it may be totally corrupted, in which case the cure would be to shut down Outlook, rename VBAProject.OTM, then restart Outlook and let Outlook create a new, clean, empty one.



"Lowell" wrote in message ...
More trouble. This morning, I tested my rule/macro again. Nothing worked. Got
an error message saying the script did not exist. Went into VB Editor and the
whole project, module, and code are gone. Most options on the menus are
unavailable, except for a few things on the Format, View and Tools menu. I
cannot create a new project or module. My security level is still set on
medium and I have checked the Help/About/Disabled items - nothing is disabled.

Any ideas on what has happened. It appears I've totally lost VB capability
within Outlook. Still have it in Excel/Word.

"Lowell" wrote:

I found the problem, at least on my PC, and just came back to post it and saw
your post, Sue. You were right on. Somehow, my Security setting had gotten
changed to High, so all macros were disabled. I got an error message (macros
disabled) when I tried to run a simple MsgBox procedure. Thanks.

"Sue Mosher [MVP-Outlook]" wrote:

Does other VBA code, such as a simple MsgBox "Hello" procedure run? Did you check the setting in Tools | Macro | Security? Does it work if you rewrite it to use the intrinsic Application object and get the message from its EntryID, as in:

Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
' do stuff with olMail, e.g.
MsgBox olMail.SUbject

Set olMail = Nothing
Set olNS = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Lowell" wrote in message ...
Created a message rule to check for a message with an attachment from a
specific sender. I set the rule to run a procedure I had created based on
info I saw here and elsewhere. Everything worked fine initially. It even
worked on a friend's PC, for whom I created the procedure.

A day or two later, friend notifies me that nothing works. Checked my system
and found the same. We have both recreated the message rule and reset it to
the procedure. No go.

The procedure is below. The first two lines after the Dim statements were
commented out initially and everything worked. Since the failure, we both
have uncommented the two lines, one at a time, to see if they were the source
of the problem. I set a a toggle break point, sent myself a message meeting
the rule's requirements, and the procedure was never accessed by the rule.
What am I missing?

Public Sub SaveAttachment(MyMail As MailItem)
Dim MyAttachment As Object
Dim MyOlApp As Object



'Set MyOlApp = CreateObject("Outlook.Application")
'Set MyMail = MyOlApp.ActiveInspector.CurrentItem
Set MyAttachment = MyMail.Attachments
MyAttachment.Item(1).SaveAsFile "C:\Documents and Settings\LB\My
Documents\temp\" & _
MyAttachment.Item(1).DisplayName

Exit Sub
End Sub



Ads