Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access to excel files not on drive C Petert Setting up and Configuration of Excel 3 May 11th 09 10:58 PM
Import from MS Access - Lose the drive letter..link only to drive Cyhill Excel Programming 6 September 17th 07 06:42 PM
user cannot access his share workbook on network drive. Phil Excel Worksheet Functions 0 September 26th 06 04:30 PM
Launching Excel causes floppy drive access Jules Excel Discussion (Misc queries) 3 March 2nd 06 02:36 AM
File in C drive is always trying to access Drive A Andre Croteau Excel Discussion (Misc queries) 3 August 9th 05 01:13 PM


All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"