-
Feb 8th, 2021, 06:42 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Open Outlook Mailbox in current window.
All,
I am working on a project with the intent to open a mailbox (one of several) from the Quick Access Toolbar, using macros and applying specific category filters. This is step 1: to open the desired mailbox in the current outlook window. The code below opens the the right folder but in a new window. I would like to open the mailbox in the current window. Any thoughts? I appreciate your help in setting me on the right path.
Code:
Sub SetCurrentFolder()
Dim strMailboxName As String
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.Folder
strMailboxName = "MailboxName"
Set myNamespace = ThisOutlookSession.GetNamespace("MAPI")
Set myFolder = myNamespace.Folders(strMailboxName)
Set myFolder = myFolder.Folders("Inbox")
myFolder.Display
ExitRoutine:
Set myFolder = Nothing
End Sub
As I stand here, on the fringes of my understanding, and look out over the
vast void before me, I realize all that lies ahead: The rest of Dot.Net. . .
-
Feb 8th, 2021, 07:22 PM
#2
Re: Open Outlook Mailbox in current window.
-
Feb 9th, 2021, 04:32 AM
#3
Re: Open Outlook Mailbox in current window.
you can try like
Code:
Set Application.ActiveExplorer.CurrentFolder = myfolder
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 9th, 2021, 05:37 PM
#4
Thread Starter
Hyperactive Member
Re: Open Outlook Mailbox in current window.
That worked great Thanks. Sorry the code is still a bit sloppy but that will be refined in time. Also thanks to jdc2000. I had perused that site earlier and believe I will have to take a deeper plunge to figure out how to set the filters.
Code:
Sub SetCurrentFolder(strMailboxName As String)
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.Folder
Set myNamespace = ThisOutlookSession.GetNamespace("MAPI")
Set myFolder = myNamespace.Folders(strMailboxName)
Set myFolder = myFolder.Folders("Inbox")
Set Application.ActiveExplorer.CurrentFolder = myFolder
ExitRoutine:
Set myNamespace = Nothing
Set myFolder = Nothing
End Sub
As I stand here, on the fringes of my understanding, and look out over the
vast void before me, I realize all that lies ahead: The rest of Dot.Net. . .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|