Get the path to My documents folder in VB6

Posted on 2006-05-05
Last Modified: 2011-09-22
Hi !

I need to get the path to the current users myDocuments folder :-)

Question by:MRSONNY
    LVL 3

    Expert Comment

    Please write your question in Detail.
    LVL 29

    Accepted Solution


    Option Explicit

    Private Declare Function SHGetSpecialFolderPathW Lib "shell32.dll" ( _
        ByVal hwndOwner As Long, _
        ByVal lpszPath As Long, _
        ByVal nFolder As Long, _
        ByVal fCreate As Long) As Boolean

    Private Const MD As Long = &H5
        Public Function My_Documents() As String
        Dim Folders(512) As Byte
        My_Documents = vbNullString
        If SHGetSpecialFolderPathW(0&, _
            ByVal VarPtr(Folders(0)), _
                MD, 0&) Then
            My_Documents = Left$(Folders, InStr(Folders, Chr$(0)) - 1)
        End If
        Erase Folders
        End Function
    Private Sub Command1_Click()
        MsgBox My_Documents
    End Sub

    Author Comment

    Hi !

    I basicly need to open a folder in the mydocuments folder of the current logged on user, like this :

    Dim rtVal As Long
    rtVal = Shell("explorer C:\Documents and Settings\USERNAME\My Documents\IncomingFiles", vbNormalFocus)
    End Sub


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now