A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How do I eliminate the "Enable Macro" selection?



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old September 16th 09, 07:15 AM posted to microsoft.public.outlook.program_vba
keith
external usenet poster
 
Posts: 71
Default How do I eliminate the "Enable Macro" selection?

I know this question hass been asked before but I was unable to make it work.
In order to make up for Outlook's inadequate handling of IMAP, I put
together a simple macro that would move messages to a folder "Trash" when
invoked. (The delete key deletes emails forever - thank you Microsoft!)

All I want to do is to enable the macro without having to manually enable it
each time I start outlook and without setting my security settings to enable
all macros.

I would appreciate any help.

Here is the code:

Sub MoveToTrash()
On Error Resume Next
Dim objFolder As MAPIFolder
Dim objNS As NameSpace, objItem As MailItem

Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.Folders("KJB").Folders("Trash")

If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If

If Application.ActiveExplorer.Selection.Count = 0 Then
Exit Sub
End If

For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.UnRead = False
objItem.Move objFolder
End If
End If
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
End Sub
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Eliminate need for "Enable Macro" selection cte67 Outlook and VBA 7 August 21st 09 06:30 PM
eliminate error message "Borlane Database Engine not installed" Outlook 2007 needs help - Outlook - Installation 2 June 5th 08 05:47 PM
How do I edit "show time as" drop down selection? DGarton Outlook - Calandaring 1 November 29th 07 10:56 PM
find/eliminate "active content" in a customized outlook form TomS Outlook - Using Forms 1 August 3rd 07 03:54 PM
how to delete email address from "to" button selection Buckskin Outlook - Using Contacts 2 June 11th 07 11:56 PM


All times are GMT +1. The time now is 11: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-2025 Outlook Banter.
The comments are property of their posters.