Function GetStrFromDLG(boolFL, strTitle)
Dim MyParam
Dim MyShellApp, MyObjFF
Dim MyStrFF
MyStrFF = ""
If boolFL = True Then
MyParam = &H4000
Else
MyParam = 0
End If
Set MyShellApp = CreateObject("Shell.Application")
Set MyObjFF = MyShellApp.BrowseForFolder(0, strTitle, MyParam, &H11)
If Not MyObjFF Is Nothing Then
MyStrFF = MyObjFF.Items.Item.path
End If
Set MyObjFF = Nothing
Set MyShellApp = Nothing
If boolFL = True Then
If CreateObject("Scripting.FileSystemObject").FolderExists(MyStrFF) = True Then
MyStrFF = ""
End If
End If
GetStrFromDLG = MyStrFF
End Function
Private Function GetStrFromDLG(boolFL As Boolean, strTitle As String) As String
Dim MyParam As Long
Dim MyShellApp As Object
Dim MyObjFF As Object
Dim MyStrFF As String
MyStrFF = ""
If boolFL = True Then
MyParam = &H4000
Else
MyParam = 0
End If
Set MyShellApp = CreateObject("Shell.Application")
Set MyObjFF = MyShellApp.BrowseForFolder(0, strTitle, MyParam, &H11)
If Not MyObjFF Is Nothing Then
MyStrFF = MyObjFF.Items.Item.path
End If
Set MyObjFF = Nothing
Set MyShellApp = Nothing
If boolFL = True Then
If CreateObject("Scripting.FileSystemObject").FolderExists(MyStrFF) = True Then
MyStrFF = ""
End If
End If
GetStrFromDLG = MyStrFF
End Function
Private Sub CmdBtn1_Click()
Me.Label1.Caption = GetStrFromDLG(True, "どうでもいいけど何かファイルを選べ。フォルダなんか選んだら無視する")
End Sub