pgbigorokuのブログ

プログラムの再利用できそうなコードをアップ

EXCEL VBA Windowsが提供しているTEMPフォルダを取得する

'
'   Windowsが提供しているTEMPフォルダを取得する
'URL https://pgbigoroku.hatenablog.com/entry/2022/08/17/090550
'参考URL https://docs.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/getspecialfolder-method
'2022/8/17
Public Function nstrWindows提供TEMPフォルダー() As String
    Dim FSO As Object
    Dim FolderObject As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set FolderObject = FSO.GetSpecialFolder(2)
    nstrWindows提供TEMPフォルダー = FolderObject.Path
    Set FolderObject = Nothing
    Set FSO = Nothing
End Function