|
|||||||
These pages are no longer updated and are only available for archive purposes.Click here to visit the pages with updated information. Select file- or folder names in WordWord has not got the method GetOpenFileName that can be used to let a user select a file name or a folder. You can use the user defined function below: Function WordApplicationGetOpenFileName(FileFilter As String, _
ReturnPath As Boolean, ReturnFile As Boolean) As String
' returns the folder and/or filename to a single user selected file
Dim strFileName As String, strPathName As String
If Not ReturnPath And Not ReturnFile Then Exit Function
If FileFilter = "" Then FileFilter = "*.*"
With Application.Dialogs(wdDialogFileOpen)
.Name = FileFilter
On Error GoTo MultipleFilesSelected
If .Display = -1 Then
strFileName = .Name
End If
On Error GoTo 0
End With
On Error GoTo 0
' remove any "-characters
If InStr(1, strFileName, " ", vbTextCompare) > 0 Then
strFileName = Mid$(strFileName, 2, Len(strFileName) - 2)
End If
If ReturnPath Then
strPathName = CurDir & Application.PathSeparator
Else
strPathName = ""
End If
If Not ReturnFile Then strFileName = ""
WordApplicationGetOpenFileName = strPathName & strFileName
MultipleFilesSelected:
End Function
Use the function like this to return a complete folder and file name:
Document last updated 2000-02-04 12:49:08 Printerfriendly version
|
|||||||
|
|||||||