Note that there are some explanatory texts on larger screens.

plurals
  1. PODirectory picker for Visual Basic macro in MS Outlook 2007
    text
    copied!<p>I wrote a Visual Basic macro for archiving attachments for Outlook 2007, but did not find a totally satisfactory way for showing a directory picker from the Outlook macro. Now, I don't know much about either Windows APIs or VB(A) programming, but the "standard" Windows file dialog I see most often in Microsoft applications would seem like an obvious choice, but it does not seem to be easily available from Outlook's macros.</p> <p>Ideally, the directory picker should at least allow to manually paste a file path/URI as a starting point for navigation, since I sometimes already have an Explorer window open for the same directory.</p> <p><em>What are the best choices for directory pickers in Outlook macros?</em></p> <p>Two things I already tried and did not find totally satisfactory are (the code is simplified and w/o error handling and probably also runs in older Outlook versions):</p> <p>1) Using <code>Shell.Application</code> which does not allow me to actually paste a starting point via the clipboard or do other operations like renaming folders:</p> <pre><code> Set objShell = CreateObject("Shell.Application") sMsg = "Select a Folder" cBits = 1 xRoot = 17 Set objBFF = objShell.BrowseForFolder(0, sMsg, cBits, xRoot) path = objBFF.self.Path </code></pre> <p>2) Using the <code>Office.FileDialog</code> from <code>Microsoft Word 12.0 Object Library</code> (via tools/references) and then using Word's file dialog, which somehow takes forever on my Vista system to appear and does not always actually bring Word to the foreground. Instead, sometimes Outlook is blocked and the file dialog is left lingering somewhere in the background:</p> <pre><code> Dim objWord As Word.Application Dim dlg As Office.FileDialog Set objWord = GetObject(, "Word.Application") If objWord Is Nothing Then Set objWord = CreateObject("Word.Application") End If objWord.Activate Set dlg = objWord.FileDialog(msoFileDialogFolderPicker) path = dlg.SelectedItems(1) </code></pre> <p>Any other ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload