Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Code to see if mapped drive exists

I have found that the "fs" object does not work in XL2007 (not where I am,
anyway). Since we moved to XL2007 I have had to switch to using "Dir" when I
want to search a directory in VBA code.
--
Time is just the thing that keeps everything from happening all at once


"BAC" wrote:

Office 2007 SP1; XP Pro SP2

I have the following code to determine if a given path has been mapped on a
user's machine:

Function fn_Test_4_Drive() As Integer
fn_Test_4_Drive = 0 'Drive does not exist
Dim fs, d, dc, n
Set fs = CreateObject("Scripting.FileSystemObject")

Set dc = fs.Drives
For Each d In dc
' Debug.Print d.sharename
If InStr(1, d.sharename, "\\crpatlfnp03\temp") 0 Then
fn_Test_4_Drive = 1
Exit Function
End If
Next d

ret = MsgBox("It appears you do not have a connection to the drive
\\crpatlfnp03\temp." & Chr(13) & _
"Please get this drive mapped for future wires.", vbOKOnly, "Missing
drive!")

End Function

Several users have the test to fail, even if the drive is mapped.

Initially I used an if fs.folderexists test, but it gave me the same
erroneous results so I went to the above Function.

Note the debug print that I used to confirm that the d.sharename being
returned was indeed the value being tested for.

Is there any reason these tests should function on some machines but not on
others?

All machines are running Office 2007 SP1; XP Pro SP2


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
Links to mapped drive change to refer to local hard drive SueD Links and Linking in Excel 1 May 8th 08 11:42 AM
pathnames to linked workbooks change from mapped drive to UNC occasionally Larry Wrinn Links and Linking in Excel 0 March 3rd 08 03:14 PM
How do I get the true path to server (not mapped drive letter)? John Excel Worksheet Functions 2 May 18th 06 09:48 PM
Excel 2003 - problem saving to a mapped network drive Chris Excel Discussion (Misc queries) 1 October 17th 05 05:57 PM
Excel converts Mapped drive to UNC - How to stop? Fred Links and Linking in Excel 1 January 20th 05 12:24 AM


All times are GMT +1. The time now is 04:30 PM.

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

About Us

"It's about Microsoft Excel"