Results 1 to 4 of 4

Thread: [RESOLVED] Open Outlook Mailbox in current window.

  1. #1

    Thread Starter
    Hyperactive Member Working.Net's Avatar
    Join Date
    Aug 2010
    Posts
    389

    Resolved [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. . .

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,391

    Re: Open Outlook Mailbox in current window.


  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  4. #4

    Thread Starter
    Hyperactive Member Working.Net's Avatar
    Join Date
    Aug 2010
    Posts
    389

    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
  •  



Click Here to Expand Forum to Full Width