View Single Post
  #5  
Old February 26th 06, 01:46 AM posted to microsoft.public.outlook.program_vba
Dean via OfficeKB.com
external usenet poster
 
Posts: 1
Default Using VBA code to move current message to a folder

Hi Michael,
I was getting an error (forget the exact error message). I combined the
advice you gave me along with some code I pulled off of the MS website and
came up with something that works (pasted below). Thanks for your help!
Best Regards,
Dean


'-----------------------------------------------------------------------------
-------------
Public Sub moveMsgToTEMP()
On Error GoTo Err_moveMsgToTEMP

'this sub moves the currently open message to the TEMP folder

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
Dim myItems As Outlook.Items
Dim myItem As Object

Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
Set myDestFolder = myInbox.Folders("TEMP")
Set myItem = Application.ActiveInspector.CurrentItem

myItem.Move myDestFolder

Exit_moveMsgToTEMP:
Exit Sub
Err_moveMsgToTEMP:
MsgBox "sub moveMsgToTEMP " & Err.Description
Resume Exit_moveMsgToTEMP
End Sub
'---------------------------------------------------------------------



Michael Bauer wrote:
Am Sat, 25 Feb 2006 11:31:37 GMT schrieb Dean:

Sorry, olFolderInbox is correct.

What do you mean by "that doesn´t work", do you get an error?

Hi Michael,
Thanks for the advice. I'm still having a problem with this line:

[quoted text clipped - 51 lines]

'---------------------------------------------------------------------------


--
Message posted via http://www.officekb.com
Ads
 

Debt Help - Debt Help - Cheat Codes - Loans - Secured Loans