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

Message Rule Does Not Run VBA Procedure



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 5th 06, 10:42 PM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default 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
Ads
  #2  
Old March 5th 06, 11:23 PM 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

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

  #3  
Old March 6th 06, 08:42 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default 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

  #4  
Old March 6th 06, 02:10 PM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default 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


  #5  
Old March 6th 06, 02:52 PM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default 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


  #6  
Old March 7th 06, 07:01 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default 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


  #7  
Old March 7th 06, 01:47 PM 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

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

  #8  
Old March 7th 06, 03:34 PM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default 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


  #9  
Old March 7th 06, 06:39 PM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default 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 --
  #10  
Old March 8th 06, 03:51 PM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default 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


 




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
Using VBA code to move current message to a folder Dean Outlook and VBA 4 February 26th 06 02:46 AM
Automatically trigger a VBA macro to run when connection to exchange server has been made. [email protected] Outlook and VBA 1 January 30th 06 11:29 PM
Automatically trigger a VBA macro to run when connection to exchange server has been made. [email protected] Outlook and VBA 0 January 25th 06 09:52 PM
Question on message rule Peter L. M. Kwan Outlook Express 2 January 25th 06 02:04 PM
Rule doesn't run automatically [email protected] Outlook - General Queries 5 January 24th 06 04:21 PM


All times are GMT +1. The time now is 12: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-2025 Outlook Banter.
The comments are property of their posters.