More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

Login

login
password
Remember me

You will need to register and log in if you want to download the source code for the Microsoft Outlook Programming book. The forums and code sharing areas are open to both registered and non-registered visitors.

forum 02-Sep-2010 22:22

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

 

    Page [ 1 ]  
 Code Essentials Printer Friendly Version
Beginner’s section on how to work in the VBA environment, how to work with functions and expressions – generally not specific to Outlook
Topic
File Browse Dialog from Form Script
How to display file choose dialog from form's script?

  23-Apr-2007  07:16
  23-Apr-2007  23:58   
Or... How to use structured types in VBScript?... (or its not possible?) I have small experience of programming VBScript...
  24-Apr-2007  07:09   
MSDN has lots of information on VBScript, which doesn't support structured types.

It's possible to display a folder browse dialog with the Shell's BrowseFolder method, but I don't know of any equivalent for browsing files.
  25-Apr-2007  23:33   
Ok, thanks
  29-Apr-2007  06:24   

'********************************************************
Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const MAX_PATH As Long = 260

Sub Select Folder
    Dim FolNm As String
    FolNm = BrowseFolder("Select a folder")
    If FolNm = "" Then
        MsgBox "You didn't select a folder"
        Exit Sub
    Else
' MsgBox "You selected: " & FolNm
    End If
End Sub

Function BrowseFolder(Optional Caption As String, _
    Optional InitialFolder As String) As String
    
    Dim SH As Shell32.Shell
    Dim F As Shell32.Folder

    Set SH = New Shell32.Shell
    Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, InitialFolder)

    If Not F Is Nothing Then
        BrowseFolder = F.Items.Item.Path
    End If
End Function
'*************************************

Hope this helps!
 
  29-Apr-2007  06:25   
Sorry, its not Sub Select Folder, But Sub SelectFolder.........

'********************************************************
Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const MAX_PATH As Long = 260

Sub Select Folder
    Dim FolNm As String
    FolNm = BrowseFolder("Select a folder")
    If FolNm = "" Then
        MsgBox "You didn't select a folder"
        Exit Sub
    Else
' MsgBox "You selected: " & FolNm
    End If
End Sub

Function BrowseFolder(Optional Caption As String, _
    Optional InitialFolder As String) As String
    
    Dim SH As Shell32.Shell
    Dim F As Shell32.Folder

    Set SH = New Shell32.Shell
    Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, InitialFolder)

    If Not F Is Nothing Then
        BrowseFolder = F.Items.Item.Path
    End If
End Function
'*************************************

Hope this helps!
 
  29-Apr-2007  07:57   
Thanks! I knew there was a trick Iwas missing -- BIF_BROWSEINCLUDEFILES
    Page [ 1 ]  
Post a new message to this topic.



name        email