Results 1 to 7 of 7

Thread: Opening a Folder in Network Drive [Resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    2

    Unhappy 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.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    4. (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
    5. ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    6.  
    7. Public Const SW_SHOWNORMAL = 1
    8.  
    9. Public Sub Main()
    10.  
    11.     ShellExecute vbNull, vbNullString, "\\ServerName\ShareName", vbNullString, vbNullString, SW_SHOWNORMAL
    12.  
    13. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349
    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?

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349
    Who knew that the ShellExecute API would open directories as well as files. Good job!!!

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    2
    Hi RobDog888,

    Thanks a million. It works like a dream.

  6. #6
    Hyperactive Member dRAMmer's Avatar
    Join Date
    Oct 2001
    Location
    strangelans
    Posts
    463
    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...

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width