Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Drive Access Error
I have an application that tests for the existence of a text file in a
network server that has been mapped to drive Z: Depending on whether the file exists determines the mode of the workbook. I use the following to check. If Len(Dir("Z:\myPath\myFile\myFile.txt")) 0 Then 'set mode 1 Else 'set mode 2 Endif The above works well even if the user has not got a Z: drive mapped. If the user has a drive Z: but does not have access rights to read the folder I get a run-time error. How can I change the test to prevent this? -- Regards, Nigel |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Drive Access Error
I'd use:
dim teststr as string teststr = "" on error resume next teststr = Dir("Z:\myPath\myFile\myFile.txt") on error goto 0 if teststr = "" then 'nope else 'yep end if Nigel wrote: I have an application that tests for the existence of a text file in a network server that has been mapped to drive Z: Depending on whether the file exists determines the mode of the workbook. I use the following to check. If Len(Dir("Z:\myPath\myFile\myFile.txt")) 0 Then 'set mode 1 Else 'set mode 2 Endif The above works well even if the user has not got a Z: drive mapped. If the user has a drive Z: but does not have access rights to read the folder I get a run-time error. How can I change the test to prevent this? -- Regards, Nigel -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Drive Access Error
if the dir() fails, it'll return an empty string.
I think this is more of a natural check: if teststr = "" then then this check: if len(teststr)=0 then But there wouldn't be a difference in function Nigel wrote: Thanks Dave, The error check fixes the permissions issue. But I am curious if testing the Length of an empty string is different to testing for the existence of "" ? Cheers -- Regards, Nigel "Dave Peterson" wrote in message ... I'd use: dim teststr as string teststr = "" on error resume next teststr = Dir("Z:\myPath\myFile\myFile.txt") on error goto 0 if teststr = "" then 'nope else 'yep end if Nigel wrote: I have an application that tests for the existence of a text file in a network server that has been mapped to drive Z: Depending on whether the file exists determines the mode of the workbook. I use the following to check. If Len(Dir("Z:\myPath\myFile\myFile.txt")) 0 Then 'set mode 1 Else 'set mode 2 Endif The above works well even if the user has not got a Z: drive mapped. If the user has a drive Z: but does not have access rights to read the folder I get a run-time error. How can I change the test to prevent this? -- Regards, Nigel -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Access to excel files not on drive C | Setting up and Configuration of Excel | |||
Import from MS Access - Lose the drive letter..link only to drive | Excel Programming | |||
user cannot access his share workbook on network drive. | Excel Worksheet Functions | |||
Launching Excel causes floppy drive access | Excel Discussion (Misc queries) | |||
File in C drive is always trying to access Drive A | Excel Discussion (Misc queries) |