みんな大好きExcel。
今回はExcelで実行できるVBAでダイアログ形式でファイルを開きパスを取得の話。
実際のところ
まずは写経。
ファイルが読み込まれるとダイアログがでてTextファイルがデフォ指定でチェックできるもの。
fileToOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If fileToOpen <> False Then MsgBox "Open " & fileToOpen End If
ボタンに連動させる場合
Private Sub CommandButton1_Click() Filename = Application.GetOpenFilename() MsgBox Filename End Sub