Run script. Outlook 2003

  • Thread starter Thread starter John Tripp
  • Start date Start date
J

John Tripp

I have a VBA procedure (see below) which runs from a rule, using the "Run
Script" option. This works fine.

I now tried to export the procedure and then import it to another machine.
The export/import works fine. I save my VBA code and try to build the rule
on the new machine. When the popup opens to select which code to run, the
list is empty.

Help!!! I have tried everything I can think of and read all the posts on
running scripts and can not see what I am doing wrong. Any ideas will be
appreciated.

Thanks, John

Declaration I am using. --------

Public Sub SaveAttachmentsToFolder(oMail As MailItem)
.........
End Sub
 
Have you copied the code into the module ThisOUtlookSession?

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool:
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Tue, 17 Jun 2008 12:34:02 -0700 schrieb John Tripp:
 
What's the name of the code module? If it has the same name as the procedure, you'll need to change one or the other.
 
Thanks, that worked for setting up the rule. However, the code does not get
executed. In order to make sure the rule was triggered, I added an
additional task to forward to another account and that happened. I added a
breakpoint at the first line of code and it does not break. In my original
application, I had the code simply in Module 1 and it works fine.

Any Ideas?
 
Macro security is set to medium.

Code on first machine is located only in Prouject1 | Modules | SaveAttach
It works fine. the rule I am using on that machine properly triggers run
SubName. It has been working for a very long time.

As you can see from the previous thread, on the second machine, I had to put
the code in ThisOutlookSession to enable the second machine rule wizard see
it. See my comments below.
 
Here's an example:

Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem
Dim rply as Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.
Set rply = msg.Reply
rply.Body = "What you want the reply to say."
rply.To = "(e-mail address removed); (e-mail address removed)"
rply.Send

Set msg = Nothing
Set rply = Nothing
Set olNS = Nothing
End Sub

For another example of a "run a script" rule actions, see:

http://www.outlookcode.com/codedetail.aspx?id=1494

CAUTION: Using this technique has been known to result in corrupt VBA code. Be sure to export your code modules or back up the VBAProject.otm file.
 
I sent this yesterday, but I think the thread is somehow broken. I see stuff
not directly related to what I am talking about. You had asked questions in
your post which I attempted to answer, I don't think you saw the reply.
Note: today, I have gone to the first machine and modified the VBA code for
some additional functionality and everything continues to run fine. Again,
new code displays same behavior on second machine. I am going to go to a
brand new machine and try again. It really does not make sense. In the
meantime, any new ideas are appreciated.

Thanks, John

Macro security is set to medium.

Code on first machine is located only in Prouject1 | Modules | SaveAttach
It works fine. the rule I am using on that machine properly triggers run
SubName. It has been working for a very long time.

As you can see from the previous thread, on the second machine, I had to put
the code in ThisOutlookSession to enable the second machine rule wizard see
it. See my comments below.
 
I know of only two scenarios in which the rules wizard doesn't see a procedure intended for use with a "run a script" rule: (1) The procedure is not constructed correctly -- doesn't have a MailItem or MeetingItem parameter or (2) The procedure has the same name as the code module. It's certainly possible that corruption in the VbaProject.otm file itself could produce odd symptoms, but that case would be a lot harder to pin down to a specifc cause.

Does the procedure work once you move it to ThisOutlookSession so you can connect it with a rule? If not, does other VBA code run at all? Are you getting the prompt to allow macros to run?

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
Sue, as I mentioned in my last post, I was going to try it on another
machine. On that machine, I built everything as on the first machine. Code
placed in "Modules" not ThisOutlook Session and the Rule works exactly as on
the first machine. I have to assume that some corruption exists on the
second machine and will run a repair tonight.

Thanks for your input and I am sorry to bother you. I should have tried it
on another machine before I got everyone involved.

Thanks all. John
 
Back
Top