Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7936139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:07:18+00:00 2026-06-03T22:07:18+00:00

I am trying to create a user form that will allow the user to

  • 0

I am trying to create a user form that will allow the user to select the folder to copy a set of emails from to an excel spreadsheet. I have done all the rest (ie created the copy process) but currently I have to manually enter the namespace and folder hierarchy for each new installation of this macro. Below is my manual process

Set ol_App = New Outlook.Application
Set ol_Namespace = ol_App.GetNamespace("MAPI")
' Set ol_Folder = olNamespace.GetDefaultFolder(olFolderInbox)

' reference the folder that the emails are stored in
Set ol_Folder = ol_Namespace.Folders("Their own namespace")
Set ol_Folder = ol_Folder.Folders("Inbox")
Set ol_Folder = ol_Folder.Folders("Required_Folder")

Now this vba will be shared among a fair few people and each person has a different setup. Is there a way I can set this up in a userform using say a list-box and all they do is select the correct folder and click continue and the folder selection is stored in a variable or some sort?

Thank you in advance,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:07:21+00:00Added an answer on June 3, 2026 at 10:07 pm

    Is this what you are trying? This will also negate the need to use a listbox. 🙂

    Option Explicit
    
    '~~> Set a reference to Outlook Object x.x Library
    Sub Sample()
        Dim oOlApp As Outlook.Application
        Dim objNmSpc As Namespace
        Dim ofldr As Object
    
        Set oOlApp = Outlook.Application
        Set objNmSpc = oOlApp.GetNamespace("MAPI")
        Set ofldr = objNmSpc.PickFolder
    
        If Not ofldr Is Nothing Then MsgBox ofldr
    End Sub
    

    And here is via Late Binding i.e, if you do not want to add the reference to Outlook Object x.x Library

    Option Explicit
    
    Sub Sample()
        Dim oOlApp As Object, objNmSpc As Object, ofldr As Object
    
        '~~> Establish an Outlook application object
        On Error Resume Next
        Set oOlApp = GetObject(, "Outlook.Application")
    
        If Err.Number <> 0 Then
            Set oOlApp = CreateObject("Outlook.Application")
        End If
        Err.Clear
        On Error GoTo 0
    
        Set objNmSpc = oOlApp.GetNamespace("MAPI")
        Set ofldr = objNmSpc.PickFolder
    
        If Not ofldr Is Nothing Then MsgBox ofldr
    End Sub
    

    EDIT:

    SNAPSHOT

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a form that will handle video file uploads from the
I'm trying to create an app in Visual Basic that will allow a user
I am trying to create an upload form that allows the user to select
I'm trying to create a web application that will allow a user to post
I'm trying to create a child form that helps the user to enter data
I am trying to create an asp.net web form that allows a user to
Hello there i'm trying to create a form with Zend_Form that will enable my
I'm trying to create a user control that will provide a draggable splitter between
I'm trying to create a simple form that will validate that the first password
I am trying to create a form that will pop up over the top

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.