dan-cat
Registered User.
- Local time
- Today, 09:53
- Joined
- Jun 2, 2002
- Messages
- 3,415
Hello,
What I am trying to do is open a filedialog and with the file selected - check to see whether the file exists. ie. Whether the the user has typed a new file name or selected an old one. This is so I can warn the user that the file will be over-written.
Here is what I have done
Dim dlgOpen As Office.FileDialog
Dim varFile As Variant
Dim strFileName As String
Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
With dlgOpen
.AllowMultiSelect = False
If dlgOpen.Show = True Then
For Each varFile In .SelectedItems
strFileName = varFile
Next
With Application.FileSearch
.NewSearch
.LookIn = ' ???
.FileName = ' ???
If .Execute() > 0 Then
MsgBox "This file already exists"
Else
MsgBox "This file does not exist"
End If
End With
End If
End With
So my problem is that I have the variable strFileName which details the entire path. How can I use that within the FileSearch command.
Thanks awfully
Dan
What I am trying to do is open a filedialog and with the file selected - check to see whether the file exists. ie. Whether the the user has typed a new file name or selected an old one. This is so I can warn the user that the file will be over-written.
Here is what I have done
Dim dlgOpen As Office.FileDialog
Dim varFile As Variant
Dim strFileName As String
Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
With dlgOpen
.AllowMultiSelect = False
If dlgOpen.Show = True Then
For Each varFile In .SelectedItems
strFileName = varFile
Next
With Application.FileSearch
.NewSearch
.LookIn = ' ???
.FileName = ' ???
If .Execute() > 0 Then
MsgBox "This file already exists"
Else
MsgBox "This file does not exist"
End If
End With
End If
End With
So my problem is that I have the variable strFileName which details the entire path. How can I use that within the FileSearch command.
Thanks awfully
Dan