I am using the following code to retrieve the full path of a user specified file:
This works in Excel 2003 VBA, but knowing that CurDir is older technology, and assuming that it will not work with Excel 2007 VBA, I have been trying to implement the FSO technology via the following code:
This code does not work because FileName must be dimmed as an Oject. But if it is dimmed as an object, it no longer works with the GetOpenFileName command. Ultimately, I am just trying to retrieve the full path of the user selected file (preferably as a string) so that it can be used with other GetOpenFileName commands. Does anyone know the solution here?
Thanks,
Paul Hudgens
Denver
Code:
With Application
FileName = .GetOpenFilename(Filter, FilterIndex, Title)
FilesFolder = CurDir()
FilesDrive = Trim(Mid(FilesFolder, 1, 1))
ChDrive (Left(.DefaultFilePath, 1))
ChDir (.DefaultFilePath)
End With
This works in Excel 2003 VBA, but knowing that CurDir is older technology, and assuming that it will not work with Excel 2007 VBA, I have been trying to implement the FSO technology via the following code:
Code:
Set fs1 = CreateObject("Scripting.FileSystemObject")
Set FPath = fs.GetFile(FileName)
FilesFolder = FPath.Path
FilesDrive = Trim(Mid(FilesFolder, 1, 1))
This code does not work because FileName must be dimmed as an Oject. But if it is dimmed as an object, it no longer works with the GetOpenFileName command. Ultimately, I am just trying to retrieve the full path of the user selected file (preferably as a string) so that it can be used with other GetOpenFileName commands. Does anyone know the solution here?
Thanks,
Paul Hudgens
Denver