よろずやネット

最近はLibreofficeにハマっています。

LibreOffice、自身のファイル情報を取得する。

LibreOffice、自身のファイル情報を取得するマクロです。
Sub SelfFileDirName

下記を取得します。
1.自身のファイル名
2.自身のファイルパス
3.自身のディレクトリ


Sub SelfFileDirName

	Dim oUrl As String
	Dim FileName As String
	Dim FilePath As String
	Dim FileDir As String

	oUrl = ThisComponent.getURL
	
'	自身のファイル名
	FileName = Dir(oUrl,0)
	MsgBox(FileName)

'	自身のファイルパス
	FilePath = ConvertFromUrl(oUrl)
	MsgBox(FilePath)

'	自身のディレクトリ
	FileDir = Replace(FilePath, FileName, "")
	MsgBox(FileDir)

End Sub 'SelfFileDirName