I have developed a workaround if anyone is interested, but would still be open to a better method.
I have written a secondary script that gets called just prior to showing the dialog:
Relevant part of the main script:
Code:
'used to activate the dialog window, when it appears in the background on Win 7
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "C:\BringFileDialogToFront.vbs"
Set objShell = Nothing
Set oWord = CreateObject("Word.Application")
Set MyFilePicker = oWord.FileDialog(3)
With MyFilePicker
.AllowMultiSelect = False
.InitialFileName = "C:\"
.Title = "Please Select the Required File"
.ButtonName = "Select"
End With
If MyFilePicker.Show = -1 Then
MyFile = MyFilePicker.SelectedItems(1)
End If
Separate script to bring the dialog to the front:
Code:
dim WshShell
dim bActivated
dim x
x = 1
set WshShell = WScript.CreateObject("WScript.Shell")
do until bActivated = True
bActivated = WshShell.AppActivate("Please Select the Required File")
WScript.Sleep 100 'wait 0.1 sec
x = x + 1
if x = 10 then bActivated = True
loop
For this to work it needs to be in a separate file. I would love to hear if someone can get this to work as part of a single script.
B
Bookmarks