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