Discussion:
File Open Dialog box in Vista
(too old to reply)
Pete Gomersall
2006-09-22 19:54:33 UTC
Permalink
Hi all,
I have been using the UserAccounts.CommonDialog from XP with my VBScripts,
however this doesn't seem to work in Vista.
Does anyone know if there is a similar ActiveX object to call in Vista or
Vista specific way to call the Common File Open dialog from VBScript?
Cheers,
Pete Gomersall
Michael Harris (MVP)
2006-09-23 00:41:49 UTC
Permalink
Post by Pete Gomersall
Hi all,
I have been using the UserAccounts.CommonDialog from XP with my
VBScripts, however this doesn't seem to work in Vista.
Does anyone know if there is a similar ActiveX object to call in
Vista or Vista specific way to call the Common File Open dialog from
VBScript? Cheers,
Pete Gomersall
Scripting Week 3 Question and Answer Log
<http://www.microsoft.com/technet/scriptcenter/webcasts/sweek3/day4qanda.mspx>

"...
What is the best alternative to 'UserAccounts.CommonDialog' for an HTA
running on Windows 2003 server?

I assume you're looking for the File Open/File Save dialog boxes; you can
use the SAFRCFileDlg object. You can find an example of using the File Save
dialog box here:
http://www.microsoft.com/technet/scriptcenter/webcasts/sweek3/you-found-it.mspx.
..."

...which points you to...

The Scripting Week 3 Giveaway
<http://www.microsoft.com/technet/scriptcenter/webcasts/sweek3/you-found-it.mspx>

Maybe SAFRCFileDlg will work on Vista?
--
Michael Harris
Microsoft MVP Scripting
Pete Gomersall
2006-09-25 15:57:06 UTC
Permalink
Michael,
Thanks for comments but I get the same error as I did using
"UserAccounts.CommonDialog from XP":
ActiveX component can't create object - SAFRCFileDlg.FileSave - Code:
800A01AD
Maybe someone from MSFT may know what the correct object call for File
Open/Save dialogs in Windows Vista is from VBScript?
Many thanks though,
Pete Gomersall,
Post by Michael Harris (MVP)
Post by Pete Gomersall
Hi all,
I have been using the UserAccounts.CommonDialog from XP with my
VBScripts, however this doesn't seem to work in Vista.
Does anyone know if there is a similar ActiveX object to call in
Vista or Vista specific way to call the Common File Open dialog from
VBScript? Cheers,
Pete Gomersall
Scripting Week 3 Question and Answer Log
<http://www.microsoft.com/technet/scriptcenter/webcasts/sweek3/day4qanda.mspx>
"...
What is the best alternative to 'UserAccounts.CommonDialog' for an HTA
running on Windows 2003 server?
I assume you're looking for the File Open/File Save dialog boxes; you can
use the SAFRCFileDlg object. You can find an example of using the File
http://www.microsoft.com/technet/scriptcenter/webcasts/sweek3/you-found-it.mspx.
..."
...which points you to...
The Scripting Week 3 Giveaway
<http://www.microsoft.com/technet/scriptcenter/webcasts/sweek3/you-found-it.mspx>
Maybe SAFRCFileDlg will work on Vista?
--
Michael Harris
Microsoft MVP Scripting
markdmac
2007-01-29 04:53:31 UTC
Permalink
SAFRCFileDlg has been deprecated by Microsoft. The DLL was not actually
intended to be used for scripting.

It iwll however still work for you on Vista. You just need to copy the
DLL from an XP machine and register it with REGSVR32. Vista security
will make you copy it to a folder other than System32 and register it
that way.
--
markdmac
------------------------------------------------------------------------
markdmac's Profile: http://forums.techarena.in/member.php?userid=21374
View this thread: http://forums.techarena.in/showthread.php?t=592925

http://forums.techarena.in
spinzr0
2008-08-19 19:51:48 UTC
Permalink
The best way I found to do it was to use word to get the file open
dialog. Here is a sample function:

Function GetFileName()
Set oWord = CreateObject("Word.Application")


oWord.ChangeFileOpenDirectory(CreateObject("Wscript.Shell").SpecialFolders("Desktop"))

oWord.FileDialog(msoFileDialogOpen).Title = "Please Select the
Additions File"
oWord.FileDialog(msoFileDialogOpen).AllowMultiSelect = False

If oWord.FileDialog(1).Show = -1 Then
oWord.WindowState = 2
For Each objFile in oWord.FileDialog(1).SelectedItems
GetFileName = objFile
Next
End If

oWord.Quit
End Function
--
spinzr0
------------------------------------------------------------------------
spinzr0's Profile: http://forums.techarena.in/members/spinzr0.htm
View this thread: http://forums.techarena.in/server-scripting/592925.htm

http://forums.techarena.in
Lance Yan
2009-05-08 02:51:08 UTC
Permalink
hey, i'v got a way to resolve this problem. Please try the code below:

on error resume next
set fso=createobject("scripting.filesystemobject")
Set WshShell=WScript.CreateObject("Shell.Application")
dirPath=WshShell.BrowseForFolder(0, "select the path", 0,
"").items().item().path
if right(dirPath,1)<>"\" then
dirPath=dirpath&"\"
end if
if dirpath="\" then
dirpath="DOCUME~1\Admini~1\desktop\"
end if
msgbox dirpath
--
Lance Yan
------------------------------------------------------------------------
Lance Yan's Profile: http://forums.techarena.in/members/97060.htm
View this thread: http://forums.techarena.in/server-scripting/592925.htm

http://forums.techarena.in
Loading...