Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Message Rule Does Not Run VBA Procedure (http://www.outlookbanter.com/outlook-vba/7555-message-rule-does-not-run.html)

Lowell March 5th 06 10:42 PM

Message Rule Does Not Run VBA Procedure
 
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

Sue Mosher [MVP-Outlook] March 5th 06 11:23 PM

Message Rule Does Not Run VBA Procedure
 
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


Michael Bauer March 6th 06 08:42 AM

Message Rule Does Not Run VBA Procedure
 
Am Sun, 5 Mar 2006 13:42:27 -0800 schrieb Lowell:

Please see click the menu bar: ?/Info, then the "Deactivated Items" button
(or something similar).

If VBA is listed there then re-activate it.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


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


Lowell March 6th 06 02:10 PM

Message Rule Does Not Run VBA Procedure
 
Michael - I'm not quite following your post. Sorry.

The menu bar - is it the one in the VB editor window or the normal Outlook
menu bar? The only question mark item I see on either menu bar activates
Help. I can't find anything showing Info or Deactivated Items. Can you give
me a little more help?

Thanks,
Lowell

"Michael Bauer" wrote:

Am Sun, 5 Mar 2006 13:42:27 -0800 schrieb Lowell:

Please see click the menu bar: ?/Info, then the "Deactivated Items" button
(or something similar).

If VBA is listed there then re-activate it.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


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



Lowell March 6th 06 02:52 PM

Message Rule Does Not Run VBA Procedure
 
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



Michael Bauer March 7th 06 07:01 AM

Message Rule Does Not Run VBA Procedure
 
Am Mon, 6 Mar 2006 05:10:52 -0800 schrieb Lowell:

I didnīt saw Sueīs answer as I wrote mine and I think the problem is solved
know, right?

To answer the new question: Itīs the menu bar in Outlook, not in the VBA
editor. Itīs possible that thereīs no "Info" button in the ? menu. In German
the button is called "Info", I donīt know the name for English Systems.
Also, maybe you need to expand the menu first (not used buttons are hidden)
by clicking in the last entry.

Sorry, know I remember, Is the button called "About..."?

"Deactivated Items" or "Deactivated Elements" (that translation I really
donīt know) is available in Outlook = 2002 only.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael - I'm not quite following your post. Sorry.

The menu bar - is it the one in the VB editor window or the normal Outlook
menu bar? The only question mark item I see on either menu bar activates
Help. I can't find anything showing Info or Deactivated Items. Can you

give
me a little more help?

Thanks,
Lowell

"Michael Bauer" wrote:

Am Sun, 5 Mar 2006 13:42:27 -0800 schrieb Lowell:

Please see click the menu bar: ?/Info, then the "Deactivated Items"

button
(or something similar).

If VBA is listed there then re-activate it.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


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



Sue Mosher [MVP-Outlook] March 7th 06 01:47 PM

Message Rule Does Not Run VBA Procedure
 
In English, it would be the Help | About Microsoft Outlook command.

--
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


"Michael Bauer" wrote in message .. .
Am Mon, 6 Mar 2006 05:10:52 -0800 schrieb Lowell:

I didnīt saw Sueīs answer as I wrote mine and I think the problem is solved
know, right?

To answer the new question: Itīs the menu bar in Outlook, not in the VBA
editor. Itīs possible that thereīs no "Info" button in the ? menu. In German
the button is called "Info", I donīt know the name for English Systems.
Also, maybe you need to expand the menu first (not used buttons are hidden)
by clicking in the last entry.

Sorry, know I remember, Is the button called "About..."?

"Deactivated Items" or "Deactivated Elements" (that translation I really
donīt know) is available in Outlook = 2002 only.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael - I'm not quite following your post. Sorry.

The menu bar - is it the one in the VB editor window or the normal Outlook
menu bar? The only question mark item I see on either menu bar activates
Help. I can't find anything showing Info or Deactivated Items. Can you

give
me a little more help?

Thanks,
Lowell

"Michael Bauer" wrote:

Am Sun, 5 Mar 2006 13:42:27 -0800 schrieb Lowell:

Please see click the menu bar: ?/Info, then the "Deactivated Items"

button
(or something similar).

If VBA is listed there then re-activate it.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


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


Lowell March 7th 06 03:34 PM

Message Rule Does Not Run VBA Procedure
 
Michael,

Yes the problem is solved, I think. However, I noticed some odd behavior
after the macro began working again. When I left my PC inactive long enough
for the password protected screen saver to activate, I would find the VB
Editor window open to my macro when I entered my password and began using the
PC again. The odd thing is the editor window would have no menu or toolbars!

I am monitoring that situation now. I have disabled my screen saver, to
determine if that is the cause or if just receiving new messages is the
cause. Will keep you posted.

Thanks again for your help.

Lowell

"Michael Bauer" wrote:

Am Mon, 6 Mar 2006 05:10:52 -0800 schrieb Lowell:

I didnÂīt saw SueÂīs answer as I wrote mine and I think the problem is solved
know, right?

To answer the new question: ItÂīs the menu bar in Outlook, not in the VBA
editor. ItÂīs possible that thereÂīs no "Info" button in the ? menu. In German
the button is called "Info", I donÂīt know the name for English Systems.
Also, maybe you need to expand the menu first (not used buttons are hidden)
by clicking in the last entry.

Sorry, know I remember, Is the button called "About..."?

"Deactivated Items" or "Deactivated Elements" (that translation I really
donÂīt know) is available in Outlook = 2002 only.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Michael - I'm not quite following your post. Sorry.

The menu bar - is it the one in the VB editor window or the normal Outlook
menu bar? The only question mark item I see on either menu bar activates
Help. I can't find anything showing Info or Deactivated Items. Can you

give
me a little more help?

Thanks,
Lowell

"Michael Bauer" wrote:

Am Sun, 5 Mar 2006 13:42:27 -0800 schrieb Lowell:

Please see click the menu bar: ?/Info, then the "Deactivated Items"

button
(or something similar).

If VBA is listed there then re-activate it.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


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



Michael Bauer March 7th 06 06:39 PM

Message Rule Does Not Run VBA Procedure
 
Am Tue, 7 Mar 2006 07:47:42 -0500 schrieb Sue Mosher [MVP-Outlook]:



In English, it would be the Help | About Microsoft Outlook command.


Thanks, Sue.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --

Lowell March 8th 06 03:51 PM

Message Rule Does Not Run VBA Procedure
 
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




All times are GMT +1. The time now is 08:43 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-2006 OutlookBanter.com