![](https://next-innovation-fuk.com/wp-content/uploads/2022/03/ウルトラワイドモニター01-1024x644-1.jpg)
ファイル選択画面を表示してファイル選択する
![うさこちゃん](https://next-innovation-fuk.com/wp-content/uploads/2021/07/yumekawa_animal_usagi.png)
うさこちゃん
このサンプルはファイル選択画面を表示します。
※選択したファイルPathを取得できます。
サンプルコード
![うさこちゃん](https://next-innovation-fuk.com/wp-content/uploads/2021/07/yumekawa_animal_usagi.png)
うさこちゃん
サンプルコードではエクセルファイルのみを表示します。
Application.GetOpenFilename(“Microsoft Excelブック,*.xls?”)
Dim StrOpenFileName As String
Dim ObjWShell As Object
Dim StrDesktop As String
'オブジェクト生成
Set ObjWShell = CreateObject("WScript.Shell")
StrDesktop = ObjWShell.SpecialFolders("Desktop")
Set ObjWShell = Nothing
ChDir StrDesktop
'ファイル選択画面表示
StrOpenFileName = Application.GetOpenFilename("Microsoft Excelブック,*.xls?")
If StrOpenFileName <> "False" Then
MsgBox StrOpenFileName '取得ファイルの表示
End If
ファイル選択画面(実行イメージ)
![](https://next-innovation-fuk.com/wp-content/uploads/2022/03/Excel-VBA-ファイル選択画面の表示してファイル選択する-1-1024x371.png)