DIR command not working

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?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Could be the links of the workbook affecting the path statement. Have you tried just copying the procedure to a new workbook on a different system? That should work OK.
 
Upvote 0

Forum statistics

Threads
1,215,479
Messages
6,125,041
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top