Created
June 21, 2012 04:37
-
-
Save nobrinskii/2963865 to your computer and use it in GitHub Desktop.
[vba/excel]フォルダのパスを選択ダイアログで取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'------------------------------------------------------------------------------- | |
'フォルダのパスを選択ダイアログで取得する | |
'------------------------------------------------------------------------------- | |
'【引数】 | |
'【戻り値】出力先のフォルダのパス | |
'【備考】選択ダイアログの初期値はデスクトップ。 | |
Private Function GetTargetFolderPath() As String | |
Dim WSH As Object | |
Dim strInitFolder As String | |
Dim strOutput As String | |
Set WSH = CreateObject("WScript.Shell") | |
strInitFolder = WSH.SpecialFolders("Desktop") & "\" | |
Set WSH = Nothing | |
With Application.FileDialog(msoFileDialogFolderPicker) | |
.Title = "フォルダを選択" | |
.AllowMultiSelect = False | |
.InitialFileName = strInitFolder | |
If .Show = True Then | |
strOutput = .SelectedItems(1) | |
End If | |
End With | |
GetTargetFolderPath = strOutput | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment