Open A Network Folder From VBA

J

Jeff Garrison

All -

I'd like to be able to open a network folder when a user clicks a button on
a form. The shared folder has a static name, but the sub folder will change
with each record. For example....

Shared Folder \\server\share\folder

Record ProjectNumber

I'd like to have it set so that when a user is in ProjectNumber 123, they
click the button and the folder \\server\share\folder\ProjectNumber opens.

Any help would be much appreciated.

Thanks.

Jeff
 
K

Kerry

Hi Jeff,

At my job all users have Windows 2000 or Windows XP, and I use
something similar to the following:

dim strFolder as String
let strFolder="\\server\share\folder" & Record

Rem if Windows 2000, Explorer in different location than XP
If Not (dir("C:\WINNT\EXPLORER.EXE") = "") Then
Shell """C:\WINNT\EXPLORER.EXE""" & " " & Chr(34) &
strFolder & Chr(34), vbNormalFocus
ElseIf Not (dir("C:\WINDOWS\EXPLORER.EXE") = "") Then
Shell """C:\WINDOWS\EXPLORER.EXE""" & " " & Chr(34) &
strFolder & Chr(34), vbNormalFocus
End If
 
G

Guest

Application.FollowHyperlink Path

Application.FollowHyperlink "\\server\share\folder\" & Me.ProjectNumber

Assuiming ProjectNumber is the name of the control on your form which house
the ProjectNumber.
 
J

Jeff Garrison

Kerry -

That's what I needed. Thanks.

Let me ask another related question...how can you create the folder if it
doesn't exist. I'd like to have the option of when the click the button, if
the folder is there, fine. If not, create it.

Thanks.

Jeff
 
C

Charles Wang[MSFT]

Hi Jeff,
I have replied you under your same post at
microsoft.public.access.formscoding. If you have any other questions or
concerns, please directly reply back under that post.

For your convenience, I would like to attach my response here:
<quote>
You may try the following code:
If Len(Dir("\\computername\ShareFolder\Test", vbDirectory)) = 0 Then
MkDir ("\\computername\ShareFolder\Test")
End If
</quote>

Thank you for your cooperation and have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top