lestercrombie
New Member
- Joined
- May 11, 2005
- Messages
- 4
I am using a function that invokes the DIR command. On my machine, that has multiple hard drives, the function works. It can check whether a directory exists on the drive the .xls file is stored on or on another drive. When I copy the .xls file with the VBA code in it to another machine, the DIR command will only work on the hard drive that the .xls file is stored on. If I try to check if a directory exists on another hard drive, it fails.
The code is:
Public Function pfFileFolderExists(strFullPath As String) As Boolean
'Purpose: Check if a file or folder exists
'Dir() returns "." if directory exists
On Error GoTo EarlyExit
If Dir(strFullPath, vbDirectory) = vbNullString Then
pfFileFolderExists = False
Else
pfFileFolderExists = True
End If
EarlyExit:
On Error GoTo 0
End Function 'FileFolderExists
OS on both machines: Windows 7 Pro (64 bit)
Microsoft Excel version on both machines: 2010
Any ideas?
The code is:
Public Function pfFileFolderExists(strFullPath As String) As Boolean
'Purpose: Check if a file or folder exists
'Dir() returns "." if directory exists
On Error GoTo EarlyExit
If Dir(strFullPath, vbDirectory) = vbNullString Then
pfFileFolderExists = False
Else
pfFileFolderExists = True
End If
EarlyExit:
On Error GoTo 0
End Function 'FileFolderExists
OS on both machines: Windows 7 Pro (64 bit)
Microsoft Excel version on both machines: 2010
Any ideas?