Jump to content
ABA3D

Need help with a script

Recommended Posts

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."the error shows up in the error console and referrs to line 5.it shows up in the error console.it shows up in the error console.it shows up in the error console.it shows up in the error console.it shows up in the error console.it shows up in the error console.it shows up in the error console.it shows up in the error console.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;	    }}

Im using IE and wraping it with HTA.thanks for ur help :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...