![]()
筆箱にVBAのカンニングペーパーを入れる係のみすくです。こんにちは。
ツール > 参照設定 > Microsoft Scripting Runtime

'---------------------------------------------------------------------------------------------------
'【処 理 名】ファイルリネーム
'【処理概要】ファイルをリネームする
'【引 数】[I]ByVal filePath As String 対象ファイルパス
' [I]ByVal newName As String 変更後のファイル名(拡張子を含む)
'【返 却 値】リネーム後ファイルのフルパス
'---------------------------------------------------------------------------------------------------
Public Function renameFile(ByVal filePath As String, ByVal newName As String) As String
'ツール > 参照設定 > Microsoft Scripting Runtime
Dim oFso As New FileSystemObject
Dim oFile As File
Set oFile = oFso.GetFile(filePath)
oFile.Name = newName
renameFile = oFile.Path
Set oFso = Nothing
Set oFile = Nothing
End Function
参考:https://msdn.microsoft.com/ja-jp/library/cc428071.aspx
最近のコメント




コメントを残す