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
  #11  
Old March 8th 06, 05:00 PM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default Message Rule Does Not Run VBA Procedure

Forgot to include this. After opening Outlook and on first attempt to access
the VB Editor, I get popup asking if I want to Disable/enable macros. This
dialog includes the project name under whihc I created the macros. Clicking
Enable results in File Not Found error being displayed. Close that dialog and
then get to the VB Editor with the problems mentioned in previous post.

"Lowell" wrote:

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
  #12  
Old March 8th 06, 05:10 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

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

  #13  
Old March 8th 06, 09:51 PM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default Message Rule Does Not Run VBA Procedure

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


  #14  
Old March 8th 06, 10:51 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

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

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


  #15  
Old March 8th 06, 11:13 PM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default Message Rule Does Not Run VBA Procedure

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 . The project name doesn't matter.

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



  #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



  #17  
Old March 9th 06, 01:30 AM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default Message Rule Does Not Run VBA Procedure

I searched and did not find it. My folder options are set to show hidden
files. I let the system search in the C:\Document and Settings folder, which
is where the user profiles are stored. I'm going to search the whole hard
disk. this is getting a little creepy, since I found the corrupted file and
can't find the newly generated one.

lowell
"Sue Mosher [MVP-Outlook]" wrote:

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




  #18  
Old March 9th 06, 02:05 AM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default Message Rule Does Not Run VBA Procedure

AHA! The file didn't get saved to the disk until I exited Outlook.

Lowell

"Lowell" wrote:

I searched and did not find it. My folder options are set to show hidden
files. I let the system search in the C:\Document and Settings folder, which
is where the user profiles are stored. I'm going to search the whole hard
disk. this is getting a little creepy, since I found the corrupted file and
can't find the newly generated one.

lowell
"Sue Mosher [MVP-Outlook]" wrote:

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




  #19  
Old March 9th 06, 07:47 PM posted to microsoft.public.outlook.program_vba
Lowell
external usenet poster
 
Posts: 13
Default Message Rule Does Not Run VBA Procedure

Sue - just wanted to say thanks one more time for your help. With this new
installation of the rule/macro, things seem much more stable. I'm not geting
that VB editor window with no menus/toolbars mysteriuosly popping up this
time. Maybe we've gotten this one handled.

Again, thank you.
Lowell

"Sue Mosher [MVP-Outlook]" wrote:

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




 




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.