View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default checking for drive

First, I wouldn't use the mapped drive.

You may connect to it via the U: drive, I may use x:. Others may not map it at
all.

I didn't test this (no access to a LAN drive):

Option Explicit
Sub testme()

Dim myUNCPath As String
Dim TestStr As String

myUNCPath = "\\server01\share\folder\"
If Right(myUNCPath, 1) < "\" Then
myUNCPath = myUNCPath & "\"
End If

TestStr = ""
On Error Resume Next
TestStr = Dir(myUNCPath & "nul")
On Error GoTo 0

If TestStr = "" Then
MsgBox myUNCPath & " isn't available"
Else
MsgBox myUNCPath & " Was found"
End If

End Sub




jnf40 wrote:

I have a workbook that saves to drive C:\ when the user clicks a button on
worksheet1. I want to have it look to see if drive U:\, a drive on a server,
is available, and if so it will save the file there, if drive U:\ is not
available then I want it to save the file to drive C:\. Any help would be
greatly appreciated.


--

Dave Peterson