Setting the focus to a dialog invoked by a WSH script

Kevin Lossner 21 Reputation points

I invoke a dialog to select some files as follows:

Set fso = CreateObject("Scripting.FileSystemObject")
Set objWord = CreateObject("Word.Application")
Set WshShell = CreateObject("WScript.Shell")


With objWord.FileDialog(msoFileDialogOpen)
.Title = "Select the files to process...."
.AllowMultiSelect = True
'Show only the desired file types
.Filters.Add "All Files", "*.rtf"


(... stuff happens....)*

But the dialog is often obscured by open folder windows, such as that containing the script I launch. How can I ensure that the dialog for selecting files will appear in the foreground?

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
514 questions
No comments
{count} votes