-
ChDrive without mapping
Hi
Normally to switch to a new drive (x, I can just write
chdrive "x:"
Howver I have access to a drive that is not mapped
So when I access the files, I have a link like
\\accounts\finance etc
I have tried to use chdrive \\accounts\finance but this does not work
Does anyone have the correct syntax when a drive is not mapped?
I don;t want to map it permanently because I get new drives all the time. So it might conflict with a new one
Thanks
-
http://www.ozgrid.com/forum/showthre...t=32173&page=1
Andy Pope's #6
As CHDIR() will not work with UNC directories try this example using an API. Change the servername and sharename to suit.
[vba]
Private Declare Function SetCurrentDirectoryA Lib "kernel32" (ByVal lpPathName As String) As Long
Sub xx()
SetUNCPath "\\servername\sharedname"
End Sub
Sub SetUNCPath(Path As String)
Dim lngStatus As Long
lngStatus = SetCurrentDirectoryA(Path)
If lngStatus = 0 Then
MsgBox "Could not set path" & vbLf & Path, vbExclamation
End If
End Sub
[/vba]
I haven't tried it yet, but I have faith in Andy
I'll also put it into my collection of subs, since I need to get data off of UNC drives also
Paul
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules