VBScript Dateiauswahl Dialog

Seite 1 von 1 - Forum: Coding Stuff auf overclockers.at

URL: https://www.overclockers.at/coding-stuff/vbscript-dateiauswahl-dialog_223316/page_1 - zur Vollversion wechseln!


Umlüx schrieb am 05.04.2011 um 13:53

ich scheitere grade daran, einen dateiauswahldialog zu basteln. nach langem rungooglen bin ich auf BrowseForFolder gestoßen, und ich kann mir die struktur damit zwar anzeigen lassen und ordner auswählen, aber keine files.

Code: VB
dim objshell, retPath
set objshell = CreateObject("Shell.Application")
set retPath = objshell.BrowseForFolder(0,"Datei Wählen", &H4241,17)
MsgBox retPath

wie mach ich es nun richtig :confused:


watchout schrieb am 05.04.2011 um 17:24

Nur eine Vermutun, hab keine Ahnung von der vbscript API:

Code: VB
objshell.BrowseForFile
? :D

Jedenfalls BrowseForFolder wird dich wohl eher nicht files auswählen lassen ;)


DKCH schrieb am 05.04.2011 um 17:28

Code: VB
Set objDialog = CreateObject("UserAccounts.CommonDialog")
'objDialog.Filter = "VBScript Scripts|*.vbs|All Files|*.*"
objDialog.Filter = "All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\Temp"
nResult = objDialog.ShowOpen

If nResult = 0 Then
MsgBox "Cancel"
Else
MsgBox objDialog.FileName
End If
?

edit: ah, geht nur bis xp, anscheinend...


Umlüx schrieb am 05.04.2011 um 23:48

tjaa browseforfile gibts leider nicht :D

und es sollte unter Win7 laufen.


watchout schrieb am 06.04.2011 um 00:40

Code: VB
Option Explicit

WScript.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 = strSelected
End Function
von http://www.robvanderwoude.com/vbstech_ui_fileopen.php (3. Hit http://www.google.com/search?q=file+dialog+in+vbscript :p)


Umlüx schrieb am 06.04.2011 um 08:46

ja die seite hab ich auch gefunden, nur die 2 oberen funktionierten nicht und beim 3. hab ich nur InternetExplorer gelesen und gedacht, das sei so für mich nicht anwendbar.

naja.. hinhauen tut das ja dennoch nicht, da er den pfad nicht liefert.




overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2025