There are a number of reasons why this special folder should not actually be used to store user documents. Microsoft and even 3rd parties have begun to use it for entirely different purposes. Depending on what applications have been installed you might even find DLLs in here.
If you mistrain users to play with this folder they might delete a file critical to the operation of some other program.
But if you insist on doing this note that it is not safe to refer to the folder by a literal string value since it can appear under varying aliases based on the user's language settings. It might even be relocated elsewhere through administrative actions.
It also hasn't been necessary to stoop to using the non-COM ShellExecute entrypoint in ages, at least as far back as version 5.0 of Shell32.dll.
This should work at least from WinXP forward:
Option Explicit
Private Const ssfCOMMONDOCUMENTS As Long = &H2E
Private Enum SHOW_WINDOW
SW_HIDE = 0
SW_SHOWNORMAL = 1
SW_SHOWMINIMIZED = 2
SW_SHOWMAXIMIZED = 3
SW_SHOWNOACTIVATE = 4
SW_SHOW = 5
SW_SHOWMINNOACTIVE = 7
SW_SHOWDEFAULT = 10
End Enum
Private Shell As Object
Private Path As String
Private Sub File1_Click()
On Error Resume Next
'Works on XP through Vista, fails on Win7:
'Shell.ShellExecute File1.FileName, , Path, "open", SW_SHOWNORMAL
'Works on XP through Win7:
Shell.ShellExecute Path & "\" & File1.FileName, , , "open", SW_SHOWNORMAL
If Err Then
MsgBox "Error " & CStr(Err.Number) & " " & Err.Description
End If
End Sub
Private Sub Form_Load()
Set Shell = CreateObject("Shell.Application")
With Shell.NameSpace(ssfCOMMONDOCUMENTS).Self
Path = .Path
End With
With File1
.Pattern = "*.doc"
.Path = Path
End With
End Sub