Setting the focus to a dialog invoked by a WSH script

Kevin Lossner 21 Reputation points
2021-07-05T21:48:21.57+00:00

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")

objWord.ChangeFileOpenDirectory("c:\")

With objWord.FileDialog(msoFileDialogOpen)
.Title = "Select the files to process...."
.AllowMultiSelect = True
.Filters.Clear
'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.
1,001 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.