- 投稿日:2020-09-24T21:21:48+09:00
Excel for macのVBAでフォルダ選択する方法
macではFileSystemObjectを使えないので、代わりにMacScriptを使ってフォルダ選択ダイアログを表示する。
Public Sub test() Dim SelectedPath As String SelectedPath = MacScript("return posix path of (choose folder with prompt ""Select the folder"") as string") Debug.Print SelectedPath End Sub実行結果
/Users/ooki/OneDrive/Documents/Qiita記事/日本語フォルダも正しく表示されてる。バッチリ。
確認バージョン
Excel for mac バージョン 16.41(20091302)