Skip to content

Instantly share code, notes, and snippets.

@nobrinskii
Created June 21, 2012 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nobrinskii/2963865 to your computer and use it in GitHub Desktop.
Save nobrinskii/2963865 to your computer and use it in GitHub Desktop.
[vba/excel]フォルダのパスを選択ダイアログで取得する
'-------------------------------------------------------------------------------
'フォルダのパスを選択ダイアログで取得する
'-------------------------------------------------------------------------------
'【引数】
'【戻り値】出力先のフォルダのパス
'【備考】選択ダイアログの初期値はデスクトップ。
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