Solved

Folder Location Dialog Box

Posted on 2006-07-10
3
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

626 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