/ Published in: Visual Basic
Used to invoke a GetSaveAsFileName dialogue box
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Function ReturnFileReference(InitialFile As String, Title As String, InitialFolder As String, FilterTo As String) As String Dim Filter As String Dim FilterIndex As Integer Dim Filename As Variant ' File filters Filter = FilterTo 'Filter = "Excel Files (*.xls),*.xls," '& _ "Text Files (*.txt),*.txt," & _ "All Files (*.*),*.*" ' Default Filter to *.* 'FilterIndex = 1 ' Set Dialog Caption ' Select Start Drive & Path ChDrive (Left(InitialFolder, 1)) ChDir (InitialFolder) With Application ' Set File Name to selected File 'Filename = .GetOpenFilename(Filter, FilterIndex, Title) Filename = .GetSaveAsFilename(InitialFile, Filter, FilterIndex, Title) ' Reset Start Drive/Path ChDrive (Left(.DefaultFilePath, 1)) ChDir (.DefaultFilePath) End With ' Exit on Cancel If Filename = False Then ReturnFileReference = "NO_FILE_SELECTED" Exit Function End If ReturnFileReference = Filename End Function