呼び出し元プロシージャ
Sub Try() Dim strPath As String Dim strFileName As String strPath = "C:\Users\デスクトップ\テスト.xlsm" strFileName = gefFileName(strPath) MsgBox strFileName End Sub
ファンクションプロシージャ
Function gefFileName(strPath As String) As String '------------------------------------------------------------- '機能:指定したファイルパスより拡張子ありのファイル名を取得する '引数1:拡張子ありのファイル名を取得したい対象のファイルパス '------------------------------------------------------------- Dim FSO As Object Set FSO = CreateObject("Scripting.FileSystemObject") gefFileName = FSO.GetFileName(strPath) End Function