ABA3D Posted July 23, 2012 Share Posted July 23, 2012 Hi I have this script that supposed to show me the path of the selected file but it shows me an error that says "Unspecified error." here is the code: function SelectFile(){var objShell = new ActiveXObject("Shell.Application"); var objFolder; objFolder = objShell.BrowseForFolder(0, "Open File", 16384); if (objFolder != null) { var oFolderItem = objFolder.Items().item() document.getElementById("fileNameS").value=oFolderItem.Path; }} thanks for ur help Link to comment Share on other sites More sharing options...
thescientist Posted July 23, 2012 Share Posted July 23, 2012 (edited) seems like you should put this in the VBScript forum. Edited July 23, 2012 by thescientist Link to comment Share on other sites More sharing options...
justsomeguy Posted July 23, 2012 Share Posted July 23, 2012 Is the error referring to a particular line? Is that a message that shows up in the error console or does the code print that message on the page? That code is also only going to work in IE, so hopefully you're using that. Link to comment Share on other sites More sharing options...
ABA3D Posted July 24, 2012 Author Share Posted July 24, 2012 yes it referrs to line 5 objFolder = objShell.BrowseForFolder(0, "Open File", 16384); it shows up in the error console.yes Im using IE Im wraping it with HTA. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 24, 2012 Share Posted July 24, 2012 It looks like several people have issues using that method. http://www.google.com/search?client=opera&rls=en&q=browseforfolder+unspecified+error&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest Link to comment Share on other sites More sharing options...
ABA3D Posted July 25, 2012 Author Share Posted July 25, 2012 Hi I found simple script that uses InternetExplorer.Application fileDialog but its in VBscript :(can u help me to convert it to javascript?!here is the code: Option ExplicitWScript.Echo "Selected file: " & ChooseFile( )Function ChooseFile( )' Select File dialog based on a script by Mayayana' Known issues:' * Tree view always opens Desktop folder' * In Win7/IE8 only the file NAME is returned correctly, the path returned will always be C:\fakepath\' * If a shortcut to a file is selected, the name of that FILE will be returned, not the shortcut's On Error Resume Next Dim objIE, strSelected ChooseFile = "" Set objIE = CreateObject( "InternetExplorer.Application" ) objIE.visible = False objIE.Navigate( "about:blank" ) Do Until objIE.ReadyState = 4 Loop objIE.Document.Write "<HTML><BODY><INPUT ID=""FileSelect"" NAME=""FileSelect"" TYPE=""file""><BODY></HTML>" With objIE.Document.all.FileSelect .focus .click strSelected = .value End With objIE.Quit Set objIE = Nothing ChooseFile = strSelectedEnd Function thanks for ur help Link to comment Share on other sites More sharing options...
justsomeguy Posted July 25, 2012 Share Posted July 25, 2012 Why do you need to convert it? If you're only going to run the code in IE then you can leave it in VBScript, IE will run that. It wouldn't work in other browsers anyway. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now