よくあるネタですが、自分メモとして。
Const ssfDESKTOP = &H0 ' Desktop Const ssfPERSONAL = &H5 ' My Documents Const ssfMYPICTURES = &H27 ' My Pictures Const ssfWINDOWS = &H24 ' Windows Function GetNewFolderPath(IstrMessage, IlngRoot) GetNewFolderPath = "" Dim objWShell, objFolder Set objWShell = WScript.CreateObject("Shell.Application") Set objFolder = objWShell.BrowseForFolder(0, IstrMessage, 0, IlngRoot) If (Not objFolder Is Nothing) Then GetNewFolderPath = objFolder.Self.Path End If Set objFolder = Nothing Set objWShell = Nothing End Function Msgbox GetNewFolderPath("Select Folder", ssfPERSONAL)
キャンセルすると空文字列が返ってくるみたいな。