Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   VBA code not starting on some Outlook 2003 clients, does on others. (http://www.outlookbanter.com/outlook-vba/14841-vba-code-not-starting-some.html)

[email protected] May 16th 06 03:53 PM

VBA code not starting on some Outlook 2003 clients, does on others.
 
I've got some code to BCC a recipient based on the who the message is
being sent to. It works great on about half of the computers I try it
on, and about half doesn't run through the code at all.
The clients are all Outlook2003, on WindowsXP.

The code is in ThisOutlookSession, but it simply ignores the code on
several computers. Does someone know of a setting or registry setting
that is causing the code to be ignored?

Thanks


[email protected] May 16th 06 04:53 PM

VBA code not starting on some Outlook 2003 clients, does on others.
 
This is the code that I am trying to run

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
Dim objMe As Recipient
If test(Item) Then
Set objMe = Item.Recipients.Add("insert bcc recipient here")
objMe.Type = olBCC
objMe.Resolve
Set objMe = Nothing
End If
End Sub

Function test(objMail As Outlook.MailItem) As Boolean
Dim objRecip As Outlook.Recipient
For Each objRecip In objMail.Recipients
'when sending email to X carbon copy Y...Enter X's email address here :
If objRecip = "recipient address here" Then
test = True
End If
Next
End Function

It runs fine on some, doesn't launch on others. Going to see if it is
just the ItemSend event or vba code in general


Michael Bauer May 17th 06 06:32 AM

VBA code not starting on some Outlook 2003 clients, does on others.
 
Am 16 May 2006 06:53:48 -0700 schrieb :

Did you check the security setting under Tools/Macros/Security? It must be
medium or low, or youŽd have to certificate the project.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
--
www.vbOffice.net --


I've got some code to BCC a recipient based on the who the message is
being sent to. It works great on about half of the computers I try it
on, and about half doesn't run through the code at all.
The clients are all Outlook2003, on WindowsXP.

The code is in ThisOutlookSession, but it simply ignores the code on
several computers. Does someone know of a setting or registry setting
that is causing the code to be ignored?

Thanks


[email protected] May 17th 06 06:21 PM

VBA code not starting on some Outlook 2003 clients, does on others.
 
Yes it was the macro security. This is one of the first things I
checked but I ruled it out quickly as I would set it to high, and it
would still work. What wasn't clear was that Outlook actually requires
a restart for that change to take effect. I tried again on mine,
setting it to high macro security, restarting Outlook and sure enough
my code wouldn't run.

Would have been nice if changing that setting gave an indication that I
need to restart Outlook for the setting to take effect, or at the very
least an error in Outlook similar to Excel when your macro secuirty is
too high for your scripts.

Thanks.



All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com