![]() |
|
|
|
#1
|
|||
|
|||
|
I am constantly switching between several different Outlook folders. A macro in my QuickSteps section (using Office 2010) would be the ideal way to quickly move from one folder to another.
I use Excel VBA a great deal but am barely familiar with Outlook VBA. It looks like it's not possible to record a macro in Outlook VBA. Can someone give me the code when I'm in my inbox to open a folder called "Feast 2022 Emails"? |
|
#2
|
|||
|
|||
|
Hope these code snippets for Inbox, Outbox, and Sent Messages get you at least part-way to your destination!
Code:
Attribute VB_Name = "GotoOutlookFolders"
Sub GotoInbox()
Dim objOlApp As Outlook.Application
Set objOlApp = CreateObject("Outlook.Application")
Dim objFolder As Outlook.Folder
Set objFolder = Session.GetDefaultFolder(olFolderInbox)
Set objOlApp.ActiveExplorer.CurrentFolder = objFolder
Set objFolder = Nothing
Set objOlApp = Nothing
End Sub
Sub GotoOutbox()
Dim objOlApp As Outlook.Application
Set objOlApp = CreateObject("Outlook.Application")
Dim objFolder As Outlook.Folder
Set objFolder = Session.GetDefaultFolder(olFolderOutbox)
Set objOlApp.ActiveExplorer.CurrentFolder = objFolder
Set objFolder = Nothing
Set objOlApp = Nothing
End Sub
Sub GotoSent()
Dim objOlApp As Outlook.Application
Set objOlApp = CreateObject("Outlook.Application")
Dim objFolder As Outlook.Folder
Set objFolder = Session.GetDefaultFolder(olFolderSentMail)
Set objOlApp.ActiveExplorer.CurrentFolder = objFolder
Set objFolder = Nothing
Set objOlApp = Nothing
End Sub
|
|
| Tags |
| folder, macro, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VBA code to run macro across all documents in folder | rmk911 | Word VBA | 11 | 04-25-2018 02:38 PM |
Code to update macros automatically in startup folder
|
dwirony | Word VBA | 4 | 01-12-2017 08:23 AM |
| VBA Code to copy file to folder and keep the original. | staicumihai | Word VBA | 3 | 10-31-2016 03:07 AM |
vba code for folder name, subfolder directory, file name & revision times
|
klpw | Excel Programming | 2 | 12-24-2015 12:31 AM |
| Macro code should find inv no in folder and send attachhed mail. | visha_1984 | Outlook | 0 | 01-30-2013 05:08 AM |