V
Vlad G.
I have the same problem but in Outlook 2003. How can I use the code below (Sub MacroRE)in my case?
Thank's in advance
Javie wrote:
Hello,I think I have solved the problem.
27-Nov-08
Hello,
I think I have solved the problem.
I did some changes in the script that you can see below, but even with that
changes my problem persists. Nevertheless I have found a way to make it work
at least until now.
What I have done is to put the invokation to the script in a rule that also
changes the category of the received emails. So the rule has two actions:
update the category of the email and exectue my script. Since I did this
change the script has worked non-stop.
Final script:
========== CODE =========Sub MacroRE(Item As Outlook.MailItem)
On Error GoTo MacroRE_err
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim newSubject As String
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(Item.EntryID)
newSubject = Replace(newSubject, "Re: ", "RE: ")newSubject =
Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
'While InStr(1, olMail.Subject, "RE: RE: ") > 0
' newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
'Wend
If newSubject <> olMail.Subject Then
olMail.Subject = newSubject
olMail.Save
End If
' Clear memory
MacroRE_exit:
Set olMail = Nothing
Set olNS = Nothing
Exit Sub
' Handle errors
MacroRE_err:
MsgBox "An unexpected error has occurred." _
& vbCrLf & "Please note and report the following information." _
& vbCrLf & "Macro Name: MacroRE" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description: " & Err.Description _
, vbCritical, "Error!"
Resume MacroRE_exit
End Sub
======== END CODE ========
Regards,
Javier
wrote:
Previous Posts In This Thread:
On Tuesday, November 11, 2008 10:40 AM
Javier Mart?ne wrote:
Outlook script macro issue
Hi,
I've created a script for use with a rule in Rules Wizard and have put it
into a module in my VbaProject.OTM. The first times that the rule runs it
works fine. However, after some time it stops working without giving any warn
or error. It seems like if it doesn't execute.
The only way I have found to make it work again is deleting the
VbaProject.OTM, restarting Outlook and typing the macro again. The problem is
that it stops working again after some executions.
Do you know any possible solution to this? I'm using Microsoft Office
Outlook 2007 (12.0.6316.5000) SP1 MSO (12.0.6320.5000).
The script is as follows:
==================
Sub RemoveDoubleRE(Item As Outlook.MailItem)
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(Item.EntryID)
olMail.Subject = Replace(olMail.Subject, "RE: ", "Re: ")
olMail.Subject = Replace(olMail.Subject, "Re: ", "Re: ")
While InStr(olMail.Subject, "Re: Re: ") > 0
olMail.Subject = Replace(olMail.Subject, "Re: Re: ", "Re: ")
Wend
olMail.Save
Set olMail = Nothing
Set olNS = Nothing
GC.Collect
GC.WaitForPendingFinalizers
End Sub
==================
Thanks in advance,
Javier
On Tuesday, November 11, 2008 4:20 PM
Michael Bauer wrote:
What are the GC.* lines good for?
What are the GC.* lines good for?
Best regards
Michael Bauer
Am Tue, 11 Nov 2008 07:40:01 -0800 schrieb Javier Mart?nez:
warn
is
On Wednesday, November 12, 2008 2:17 AM
JavierMartne wrote:
I don't know it exactly.
I don't know it exactly. Reading a forum someone recommended putting them at
the end of the script. I tried to solve me problem with them but it remains
the same. So the script stops working with and without those lines.
"Michael Bauer " wrote:
On Wednesday, November 12, 2008 9:21 AM
- wrote:
The GC lines are not something that should be in an Outlook macro or script.
The GC lines are not something that should be in an Outlook macro or script.
They are for calling the managed code garbage collector when using a
language like C# or VB.NET, not for VBA code.
"Javier Mart??nez" <JavierMartnez> wrote in message
news:6B8C8290-948A-4997-83F9-916EB7BE1DC9@microsoft.com...
On Wednesday, November 12, 2008 11:03 AM
JavierMartne wrote:
OK. I deleted them but the problem persists.
OK. I deleted them but the problem persists. After some executions the script
stops working without giving any notice.
Regards,
Javier
wrote:
On Wednesday, November 12, 2008 1:53 PM
- wrote:
Any error in a rule script will disable that script and the rule.
Any error in a rule script will disable that script and the rule. Is your
rule being disabled? If so you have to look to see what errors are being
generated by your code.
"Javier Mart??nez" <JavierMartnez> wrote in message
newsB9E8B2B-4451-4E53-AA19-04AC73E74613@microsoft.com...
On Wednesday, November 12, 2008 3:42 PM
JavierMartne wrote:
First of all thanks for your help.
First of all thanks for your help.
Curiously when it stops working the rule remains active in the rules
configuration option. In fact, its checkbox is still marked. If there were
any errors, where could I find them and wouldn???t it fail always instead of
after some right executions?
wrote:
On Wednesday, November 12, 2008 4:21 PM
- wrote:
Normally it would disable the rule if the script threw an error and since you
Normally it would disable the rule if the script threw an error and since
you have no error handling there I'd expect to see an error message if the
script code did fire an error.
It's possible that only certain items are causing errors, but that doesn't
explain it not showing any error messages. About the only thing I can think
of would be to simplify and temporarily comment out most of the script code
and see if it stops running then. If it doesn't then uncomment lines one at
a time and see when it stops running.
"Javier Mart??nez" <JavierMartnez> wrote in message
news:E812E365-FCDA-4E51-85BA-C5E4CA356B2F@microsoft.com...
On Thursday, November 27, 2008 12:55 PM
Javie wrote:
Hello,I think I have solved the problem.
Hello,
I think I have solved the problem.
I did some changes in the script that you can see below, but even with that
changes my problem persists. Nevertheless I have found a way to make it work
at least until now.
What I have done is to put the invokation to the script in a rule that also
changes the category of the received emails. So the rule has two actions:
update the category of the email and exectue my script. Since I did this
change the script has worked non-stop.
Final script:
========== CODE =========Sub MacroRE(Item As Outlook.MailItem)
On Error GoTo MacroRE_err
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim newSubject As String
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(Item.EntryID)
newSubject = Replace(newSubject, "Re: ", "RE: ")newSubject =
Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
'While InStr(1, olMail.Subject, "RE: RE: ") > 0
' newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
'Wend
If newSubject <> olMail.Subject Then
olMail.Subject = newSubject
olMail.Save
End If
' Clear memory
MacroRE_exit:
Set olMail = Nothing
Set olNS = Nothing
Exit Sub
' Handle errors
MacroRE_err:
MsgBox "An unexpected error has occurred." _
& vbCrLf & "Please note and report the following information." _
& vbCrLf & "Macro Name: MacroRE" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description: " & Err.Description _
, vbCritical, "Error!"
Resume MacroRE_exit
End Sub
======== END CODE ========
Regards,
Javier
wrote:
Get Silverlight 4 Installed: Tips and Tricks
http://www.eggheadcafe.com/tutorial...b-f54c56a64ed9/get-silverlight-4-install.aspx
Thank's in advance
Javie wrote:
Hello,I think I have solved the problem.
27-Nov-08
Hello,
I think I have solved the problem.
I did some changes in the script that you can see below, but even with that
changes my problem persists. Nevertheless I have found a way to make it work
at least until now.
What I have done is to put the invokation to the script in a rule that also
changes the category of the received emails. So the rule has two actions:
update the category of the email and exectue my script. Since I did this
change the script has worked non-stop.
Final script:
========== CODE =========Sub MacroRE(Item As Outlook.MailItem)
On Error GoTo MacroRE_err
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim newSubject As String
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(Item.EntryID)
newSubject = Replace(newSubject, "Re: ", "RE: ")newSubject =
Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
'While InStr(1, olMail.Subject, "RE: RE: ") > 0
' newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
'Wend
If newSubject <> olMail.Subject Then
olMail.Subject = newSubject
olMail.Save
End If
' Clear memory
MacroRE_exit:
Set olMail = Nothing
Set olNS = Nothing
Exit Sub
' Handle errors
MacroRE_err:
MsgBox "An unexpected error has occurred." _
& vbCrLf & "Please note and report the following information." _
& vbCrLf & "Macro Name: MacroRE" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description: " & Err.Description _
, vbCritical, "Error!"
Resume MacroRE_exit
End Sub
======== END CODE ========
Regards,
Javier
wrote:
Previous Posts In This Thread:
On Tuesday, November 11, 2008 10:40 AM
Javier Mart?ne wrote:
Outlook script macro issue
Hi,
I've created a script for use with a rule in Rules Wizard and have put it
into a module in my VbaProject.OTM. The first times that the rule runs it
works fine. However, after some time it stops working without giving any warn
or error. It seems like if it doesn't execute.
The only way I have found to make it work again is deleting the
VbaProject.OTM, restarting Outlook and typing the macro again. The problem is
that it stops working again after some executions.
Do you know any possible solution to this? I'm using Microsoft Office
Outlook 2007 (12.0.6316.5000) SP1 MSO (12.0.6320.5000).
The script is as follows:
==================
Sub RemoveDoubleRE(Item As Outlook.MailItem)
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(Item.EntryID)
olMail.Subject = Replace(olMail.Subject, "RE: ", "Re: ")
olMail.Subject = Replace(olMail.Subject, "Re: ", "Re: ")
While InStr(olMail.Subject, "Re: Re: ") > 0
olMail.Subject = Replace(olMail.Subject, "Re: Re: ", "Re: ")
Wend
olMail.Save
Set olMail = Nothing
Set olNS = Nothing
GC.Collect
GC.WaitForPendingFinalizers
End Sub
==================
Thanks in advance,
Javier
On Tuesday, November 11, 2008 4:20 PM
Michael Bauer wrote:
What are the GC.* lines good for?
What are the GC.* lines good for?
Best regards
Michael Bauer
Am Tue, 11 Nov 2008 07:40:01 -0800 schrieb Javier Mart?nez:
warn
is
On Wednesday, November 12, 2008 2:17 AM
JavierMartne wrote:
I don't know it exactly.
I don't know it exactly. Reading a forum someone recommended putting them at
the end of the script. I tried to solve me problem with them but it remains
the same. So the script stops working with and without those lines.
"Michael Bauer " wrote:
On Wednesday, November 12, 2008 9:21 AM
- wrote:
The GC lines are not something that should be in an Outlook macro or script.
The GC lines are not something that should be in an Outlook macro or script.
They are for calling the managed code garbage collector when using a
language like C# or VB.NET, not for VBA code.
"Javier Mart??nez" <JavierMartnez> wrote in message
news:6B8C8290-948A-4997-83F9-916EB7BE1DC9@microsoft.com...
On Wednesday, November 12, 2008 11:03 AM
JavierMartne wrote:
OK. I deleted them but the problem persists.
OK. I deleted them but the problem persists. After some executions the script
stops working without giving any notice.
Regards,
Javier
wrote:
On Wednesday, November 12, 2008 1:53 PM
- wrote:
Any error in a rule script will disable that script and the rule.
Any error in a rule script will disable that script and the rule. Is your
rule being disabled? If so you have to look to see what errors are being
generated by your code.
"Javier Mart??nez" <JavierMartnez> wrote in message
newsB9E8B2B-4451-4E53-AA19-04AC73E74613@microsoft.com...
On Wednesday, November 12, 2008 3:42 PM
JavierMartne wrote:
First of all thanks for your help.
First of all thanks for your help.
Curiously when it stops working the rule remains active in the rules
configuration option. In fact, its checkbox is still marked. If there were
any errors, where could I find them and wouldn???t it fail always instead of
after some right executions?
wrote:
On Wednesday, November 12, 2008 4:21 PM
- wrote:
Normally it would disable the rule if the script threw an error and since you
Normally it would disable the rule if the script threw an error and since
you have no error handling there I'd expect to see an error message if the
script code did fire an error.
It's possible that only certain items are causing errors, but that doesn't
explain it not showing any error messages. About the only thing I can think
of would be to simplify and temporarily comment out most of the script code
and see if it stops running then. If it doesn't then uncomment lines one at
a time and see when it stops running.
"Javier Mart??nez" <JavierMartnez> wrote in message
news:E812E365-FCDA-4E51-85BA-C5E4CA356B2F@microsoft.com...
On Thursday, November 27, 2008 12:55 PM
Javie wrote:
Hello,I think I have solved the problem.
Hello,
I think I have solved the problem.
I did some changes in the script that you can see below, but even with that
changes my problem persists. Nevertheless I have found a way to make it work
at least until now.
What I have done is to put the invokation to the script in a rule that also
changes the category of the received emails. So the rule has two actions:
update the category of the email and exectue my script. Since I did this
change the script has worked non-stop.
Final script:
========== CODE =========Sub MacroRE(Item As Outlook.MailItem)
On Error GoTo MacroRE_err
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim newSubject As String
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(Item.EntryID)
newSubject = Replace(newSubject, "Re: ", "RE: ")newSubject =
Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
'While InStr(1, olMail.Subject, "RE: RE: ") > 0
' newSubject = Replace(newSubject, "RE: RE: ", "RE: ")
'Wend
If newSubject <> olMail.Subject Then
olMail.Subject = newSubject
olMail.Save
End If
' Clear memory
MacroRE_exit:
Set olMail = Nothing
Set olNS = Nothing
Exit Sub
' Handle errors
MacroRE_err:
MsgBox "An unexpected error has occurred." _
& vbCrLf & "Please note and report the following information." _
& vbCrLf & "Macro Name: MacroRE" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description: " & Err.Description _
, vbCritical, "Error!"
Resume MacroRE_exit
End Sub
======== END CODE ========
Regards,
Javier
wrote:
Get Silverlight 4 Installed: Tips and Tricks
http://www.eggheadcafe.com/tutorial...b-f54c56a64ed9/get-silverlight-4-install.aspx