![]() |
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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
#11
|
|||
|
|||
![]() The code should also work with OL03. Do you get any errors? -- Best regards Michael Bauer - MVP Outlook Category Manager - Manage and share your categories: SAM - The Sending Account Manager: http://www.vboffice.net/product.html?lang=en Am Sun, 25 Apr 2010 04:38:22 -0700 schrieb 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, " ", " ")newSubject = Replace(newSubject, " ", " ") newSubject = Replace(newSubject, " ", " ") newSubject = Replace(newSubject, " ", " ") newSubject = Replace(newSubject, " ", " ") 'While InStr(1, olMail.Subject, " ") 0 ' newSubject = Replace(newSubject, " ", " ") '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 "Ken Slovak - [MVP - Outlook]" 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, " ", " ") olMail.Subject = Replace(olMail.Subject, " ", " ") While InStr(olMail.Subject, " ") 0 olMail.Subject = Replace(olMail.Subject, " ", " ") 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 [MVP - Outlook] wrote: What are the GC.* lines good for? What are the GC.* lines good for? -- Best regards Michael Bauer - MVP Outlook 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 [MVP - Outlook]" wrote: On Wednesday, November 12, 2008 9:21 AM Ken Slovak - [MVP - Outlook] 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. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Javier Mart??nez" wrote in message ... 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 "Ken Slovak - [MVP - Outlook]" wrote: On Wednesday, November 12, 2008 1:53 PM Ken Slovak - [MVP - Outlook] 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. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Javier Mart??nez" wrote in message news ![]() 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? "Ken Slovak - [MVP - Outlook]" wrote: On Wednesday, November 12, 2008 4:21 PM Ken Slovak - [MVP - Outlook] 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. |
Ads |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Getting a button for my VB Script macro in outlook | Matt L | Outlook and VBA | 1 | April 10th 08 02:54 AM |
Very strange issue with Outlook 2007 macro | Joe G[_2_] | Outlook and VBA | 2 | August 10th 07 06:30 PM |
Email Selected or Not Macro Script | [email protected] | Outlook and VBA | 4 | May 4th 07 11:00 PM |
Server-side rule with script or macro | Brian Canner | Outlook and VBA | 1 | February 12th 07 07:59 PM |
multiple macro/script in 1 outlook | ah | Outlook and VBA | 7 | June 22nd 06 03:04 AM |