実務では、参照先のフォルダーは毎回同じとは限らないです。今日は、ユーザーがダイアログで参照先のフォルダーパス取得を見て行きましょう。
 

参照ダイアログでフォルダーのパスを取得

 

Sub test()

    ’ フォルダ選択

    Dim myPath As String
    With Application.FileDialog(msoFileDialogFolderPicker)
        If .Show = True Then


               ’ フルパスを表示する
              myPath = .SelectedItems(1)
              MsgBox myPath
        End If
      
    End With

 

End Sub

 

実行結果

 

 

 

― ― ― ― ― ― ― ― ― ― → Excel VBA基礎入門もくじ へ戻る 

 

参考記事