Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dir code fails

Status
Not open for further replies.

jeffmoore64

Programmer
Mar 23, 2005
207
US
This code throws the error " Bad filename or number" at the arrow.
The path does exsist on the remote pc.
It does work if I use a local folder though.
Any suggestions on how to get around this?


Dim stAppName As String
Dim stFolder As String

stFolder = "\\waterloo16\shared"

-> If Len(Dir(stFolder, vbDirectory)) <> 0 Then
stAppName = "Explorer.exe /n,/e,/root," & stFolder
Call Shell(stAppName, 1)
Else
MsgBox "The directory does not exist!", vbCritical
End If
 




Hi,

"The path does exsist on the remote pc."

What does that mean?

Can you actually may to that server?

I ran your code sucessfully using a remote server.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
yes the path does exist.

Try changing the path or share name to one that doesn't exist.
What will happen is that it will open windose explorer to your root c: dir
 
Here is my work around....



Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

Dim stAppName As String
Dim stFolder As String
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")

stFolder = "\\waterloo16\shared\"

Set f = fs.GetFolder(stFolder)

stAppName = "Explorer.exe /n,/e,/root," & stFolder

Call Shell(stAppName, 1)

Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox "boom", vbCritical
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub
 




Changing to a path that does not exist DOES throw an error; not as you describe.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top