File Open Dialog box in Vista

606 views
Skip to first unread message

Pete Gomersall

unread,
Sep 22, 2006, 3:54:33 PM9/22/06
to
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)

unread,
Sep 22, 2006, 8:41:49 PM9/22/06
to

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

unread,
Sep 25, 2006, 11:57:06 AM9/25/06
to
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,

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:%23%23vgJkq3...@TK2MSFTNGP02.phx.gbl...

markdmac

unread,
Jan 28, 2007, 11:53:31 PM1/28/07
to

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

unread,
Aug 19, 2008, 3:51:48 PM8/19/08
to

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

unread,
May 7, 2009, 10:51:08 PM5/7/09
to

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

Reply all
Reply to author
Forward
0 new messages