Solved

Folder Location Dialog Box

Posted on 2006-07-10
3
264 Views
Last Modified: 2010-04-08
i'm looking to have a browse button so a folder can be selected for both saving a file and another to open a file. As there are many files to open, i just need the folder location not the file location. How do i activate the dialog box as most code i've seen in excel and other vb doesn't work in outlook?
0
Comment
Question by:james_daley
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 17078553
Hi james_daley,

Try this.  Usage is:

    strSelectedFolderPath = BrowseForFolder()

The value returned will either be a complete folder path or the string "User cancelled".  This works great with Office 2003.  Not sure about previous versions of Office.  It uses the FileDialog object which is available in Word, Excel, and Access (and perhaps other Office apps), but was left out of Outlook.

Function BrowseForFolder() As String
    Dim objWord As Object, _
        objDialog As Object, _
        strPath As String
    Set objWord = CreateObject("Word.Application")
    Set objDialog = objWord.FileDialog(4)   '4 = msoFileDialogFolderPicker
    With objWord
        .Width = 0
        .Height = 0
        .WindowState = 2                              '2 = wdWindowStateMinimize
        If Not .Visible Then .Visible = True
    End With
    With objDialog
        .InitialView = 1                                  '1 =msoFileDialogViewList
        If .Show = -1 Then
            strPath = objDialog.SelectedItems(1) & "\"
        Else
            strPath = "User cancelled"
        End If
    End With
    objWord.Visible = False
    objWord.Quit False
    Set objDialog = Nothing
    Set objWord = Nothing
    BrowseForFolder = strPath
End Function


Cheers!
0
 
LVL 1

Author Comment

by:james_daley
ID: 17078998
Works very well thankyou! You wouldn't happen to know how to use the Windows API to browse for the folder would you?
0
 
LVL 1

Author Comment

by:james_daley
ID: 17079384
Not to worry, found some code that works as good as yours, thanks again.

P.S i also have another outlook question that's kinda needed asap so if ya not busy and want some easy points, jump in!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't know how to downgrade, my instructions below should be helpful.
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question