|
-
Sep 6th, 2004, 10:35 PM
#1
Thread Starter
New Member
Opening a Folder in Network Drive [Resolved]
Hi VB Experts,
I've been trying to find a code that can open a folder in a network drive.
The function is similar to by typing the UNC path (ie. "\\servername\shared") and clicking OK from the Windows Start > Run menu.
FYI, the network drive is automatically mapped during log on.
I need this code to run a small program to open shared network folders instead of typing the path on the run menu everytime.
Thanks in advance!
Richard
Last edited by rjker; Sep 6th, 2004 at 10:59 PM.
-
Sep 6th, 2004, 10:43 PM
#2
VB Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Const SW_SHOWNORMAL = 1
Public Sub Main()
ShellExecute vbNull, vbNullString, "\\ServerName\ShareName", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 6th, 2004, 10:44 PM
#3
First of all, do you know how to open the folders of your own harddrive using Visual Basic? Using Shell() won't work cause it only opens applications or files. But if you can figure out how to open folders of your own harddrive using a program, then you should be able to open a folder using a network path rather than using a local directory path. Would be interesting to know though.
Experts anyone?
-
Sep 6th, 2004, 10:46 PM
#4
Who knew that the ShellExecute API would open directories as well as files. Good job!!!
-
Sep 6th, 2004, 10:59 PM
#5
Thread Starter
New Member
Hi RobDog888,
Thanks a million. It works like a dream.
-
Sep 6th, 2004, 11:01 PM
#6
Hyperactive Member
i'm late again...
using RobDog888's code and knowing that the folder is already mapped (as you mentioned) then do:
Code:
Shell "C:\WINNT\explorer.exe X:\", vbMaximizedFocus
where X:\ is the mapped drive
i just like to clear up RobDog's way is to use API, what I posted just used the explorer windows' provided for us (this is for Jacob Roman's question)
Last edited by dRAMmer; Sep 6th, 2004 at 11:04 PM.
live, code and die...
-
Sep 6th, 2004, 11:14 PM
#7
No prob.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|
Click Here to Expand Forum to Full Width
|