M
Mick
I found a thread that has code on how to do what I'm trying to do, but
I'm missing something and it won't work. I know the macro is running,
becasue if I have the folder name I do get the eror message coded in
it. Can somone sugest where I might be going wrong. Here's the code and
the previous thread:
Oh yea, I didn't see where you assign a 'hot key' to a macro in outlook
either...
Thanks!
Mick
------------------------------------------
Eric Legault [MVP - Outlook]
Dec 11 2004, 1:47 am show options
Newsgroups: microsoft.public.outlook.program_vba
From: "Eric Legault [MVP - Outlook]" <[email protected]> -
Find messages by this author
Date: Fri, 10 Dec 2004 22:47:02 -0800
Local: Sat, Dec 11 2004 1:47 am
Subject: RE: create a macro to move outlook 2003 message to a specific
fold
Reply to Author | Forward | Print | Individual Message | Show original
| Report Abuse
Okay, now that I know exactly what you want, I've altered the macro to
handle
any selected messages in the current folder, and to look for the folder
name
that you specify underneath the root of the same store containing your
Inbox:
Sub MoveSelectedMessagesToFolder()
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Parent.Folders("Some Folder Under The
Root")
'Assume this is a mail folder
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is
selected
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
:
- Hide quoted text -
- Show quoted text -
I'm missing something and it won't work. I know the macro is running,
becasue if I have the folder name I do get the eror message coded in
it. Can somone sugest where I might be going wrong. Here's the code and
the previous thread:
Oh yea, I didn't see where you assign a 'hot key' to a macro in outlook
either...
Thanks!
Mick
------------------------------------------
Eric Legault [MVP - Outlook]
Dec 11 2004, 1:47 am show options
Newsgroups: microsoft.public.outlook.program_vba
From: "Eric Legault [MVP - Outlook]" <[email protected]> -
Find messages by this author
Date: Fri, 10 Dec 2004 22:47:02 -0800
Local: Sat, Dec 11 2004 1:47 am
Subject: RE: create a macro to move outlook 2003 message to a specific
fold
Reply to Author | Forward | Print | Individual Message | Show original
| Report Abuse
Okay, now that I know exactly what you want, I've altered the macro to
handle
any selected messages in the current folder, and to look for the folder
name
that you specify underneath the root of the same store containing your
Inbox:
Sub MoveSelectedMessagesToFolder()
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Parent.Folders("Some Folder Under The
Root")
'Assume this is a mail folder
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is
selected
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
:
- Hide quoted text -
- Show quoted text -