sjlevine34
New member
- Local time
- Today, 00:27
- Joined
- May 14, 2014
- Messages
- 5
I am using the following code to select files using Microsoft Office's file dialog:
Public Function fTestFilePicker() As String
Dim fdFileSelection As Office.FileDialog, lstrFileName As String
Const kInitialFile = "F:\Testbed\Test.txt"
Set fdFileSelection = Application.FileDialog(msoFileDialogFilePicker)
With fdFileSelection
.AllowMultiSelect = False
.Title = "Select File to be Hyperlinked:"
.Filters.Clear
.InitialFileName = kInitialFile
.InitialView = msoFileDialogViewDetails
If .Show = True Then
lstrFileName = .SelectedItems(1)
Else
lstrFileName = "Operation cancelled"
End If
End With
fTestFilePicker = lstrFileName
End Function
When I execute it, the file picker goes to the right folder but does not highlight the file test.txt even though that file name shows in the File name text box. Is there any way to correct this?
Public Function fTestFilePicker() As String
Dim fdFileSelection As Office.FileDialog, lstrFileName As String
Const kInitialFile = "F:\Testbed\Test.txt"
Set fdFileSelection = Application.FileDialog(msoFileDialogFilePicker)
With fdFileSelection
.AllowMultiSelect = False
.Title = "Select File to be Hyperlinked:"
.Filters.Clear
.InitialFileName = kInitialFile
.InitialView = msoFileDialogViewDetails
If .Show = True Then
lstrFileName = .SelectedItems(1)
Else
lstrFileName = "Operation cancelled"
End If
End With
fTestFilePicker = lstrFileName
End Function
When I execute it, the file picker goes to the right folder but does not highlight the file test.txt even though that file name shows in the File name text box. Is there any way to correct this?