Re: Outlook 2003 Macro Causes VBA to be Disabled
From: Ken Slovak - [MVP - Outlook] (kenslovak_at_mvps.org)
Date: 07/07/04
- Next message: Ken Slovak - [MVP - Outlook]: "Re: programatically access a form in your personal forms folder"
- Previous message: StargateFanFromWork: "Re: Syntax for setting Word as editor, and syntax for resetting back?"
- In reply to: Clif Haugen: "Outlook 2003 Macro Causes VBA to be Disabled"
- Next in thread: David C. Jenner: "Re: Outlook 2003 Macro Causes VBA to be Disabled"
- Reply: David C. Jenner: "Re: Outlook 2003 Macro Causes VBA to be Disabled"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 7 Jul 2004 17:06:32 -0400
I can see problems from this line:
Set objApp = New Application
Why do that at all? Just use Application. That's an intrinsic object in
Outlook VBA and Outlook 2003 VBA code is very sensitive to things like that.
New Application will produce untrusted VBA code and inherently any Outlook
VBA code that uses the built-in Application object and derives all other
Outlook objects from that is considered as trusted.
I'd also fully qualify all my declarations, not As NameSpace but As
Outlook.NameSpace and so on.
-- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Clif Haugen" <cliffo41@hotmail.com> wrote in message news:fcdc0f23.0407071210.505c1cfa@posting.google.com... > The following code works fine in Outlook 2000 and 2002. However, in > 2003 the code runs fine but the next time Outlook is started it will > disable the VBA module. > > I've tried to replace the .OTM file for the session and that hasn't > fixed the problem. I've also replaced all of my Outlook.Application > syntax with just Application. That hasn't worked. I've also looked > for any missing Set statements, but can't locate any. > > The offending code is below. I can't claim to have created it - it > was posted in this newsgroup some time ago. I've made a few > modifications and find it very helpful for dealing with Junk Senders. > > I would _really_ appreciate any thoughts!! > > Clifford > > Private Const JUNK_SENDERS_FILE As String = _ > "C:\Documents and Settings\jim smartt\Application > Data\Microsoft\Outlook\Junk Senders.txt" > > > Public Sub MultipleJunkEMailSenders() > Dim objNS As NameSpace > Dim objApp As Application > Dim objExp As Explorer > Dim objMessage As Object > Dim objMailItem As MailItem > Dim objReply As MailItem > Dim objItems As Items > Dim objExplorer As Explorer > Dim intItem As Integer > Dim objFSO As Scripting.FileSystemObject > Dim objTextStream As Scripting.TextStream > Dim CPH As String > > Set objApp = New Application > Set objNS = objApp.GetNamespace("MAPI") > Set objExp = objApp.ActiveExplorer > Set objFSO = New Scripting.FileSystemObject > > If objFSO.FileExists(FileSpec:=JUNK_SENDERS_FILE) = False Then > Set objTextStream = objFSO.CreateTextFile _ > (FileName:=JUNK_SENDERS_FILE) > Else > Set objTextStream = objFSO.OpenTextFile _ > (FileName:=JUNK_SENDERS_FILE, IOMode:=ForAppending) > End If > > Set objExplorer = Application.ActiveExplorer > > For Each objMessage In objExplorer.Selection > > Set objMailItem = objMessage > Set objReply = objMailItem.Reply > CPH = objReply.Recipients.Item(1).Address > objReply.Close olDiscard > objTextStream.WriteLine Text:=CPH > objMailItem.UnRead = True > objMailItem.Delete > > Next objMessage > > End Sub
- Next message: Ken Slovak - [MVP - Outlook]: "Re: programatically access a form in your personal forms folder"
- Previous message: StargateFanFromWork: "Re: Syntax for setting Word as editor, and syntax for resetting back?"
- In reply to: Clif Haugen: "Outlook 2003 Macro Causes VBA to be Disabled"
- Next in thread: David C. Jenner: "Re: Outlook 2003 Macro Causes VBA to be Disabled"
- Reply: David C. Jenner: "Re: Outlook 2003 Macro Causes VBA to be Disabled"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|