Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: To get the path to the "TEMP" folder

  1. #1
    New Member
    Join Date
    Sep 2004
    Posts
    38
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default To get the path to the "TEMP" folder

    Hi!
    I would appreciate very much any piece of VBA code that turns the path to the "TEMP" environment variable. Any disparate VBA keyword is also appreciated.
    Thanks in advance!

  2. #2
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    848
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Environ function for accessing operating system environment variables

    str_tmppath = Environ("temp")

    Or may be another way, if you need to return Temporary System Folder, filesytem object's GetSpecialFolder method.

    Function get_TempFolder()
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    get_TempFolder = fso.GetSpecialFolder(2)
    End Function

    Suat

  3. #3
    MrExcel MVP Joe Was's Avatar
    Join Date
    Feb 2002
    Location
    Central Florida, USA
    Posts
    7,539
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Private Function BrowseForFolder(Title As String, Optional RootFolder As Variant) As String
    'Standard module code, like: Module1!
    Dim Shell As Object, Folder As Object

    Set Shell = CreateObject("Shell.Application")
    Set Folder = Shell.BrowseForFolder(0, Title, 0, RootFolder)

    If (Not Folder Is Nothing) Then _
    BrowseForFolder = Folder.ParentFolder.ParseName(Folder.Title).Path
    End Function

    Sub browzLocalPC()
    'Standard module code, like: Module1!
    Dim myPath As String

    '*** User Option! ************************** Change "num" here for options! ***
    myPath = BrowseForFolder("Please select your folder", 17)

    '0 or missing=MS Win DesktopĀ-virtual folder that is the root of the namespace.
    '2=File system directory, the user's program groups (also file system directories). Like: C:\Documents and Settings\username\Start Menu\Programs.
    '3=Virtual folder icons for the Control Panel applications.
    '4=Virtual folder installed printers.
    '5=File system directory, for user's documents. Like: C:\Documents and Settings\username\My Documents.
    '6=File system directory, for the user's favorite items. Like: C:\Documents and Settings\username\Favorites.
    '7=File system directory, the Startup program group that starts on log to Win NT or Win 95. Like: C:\Documents and Settings\username\Start Menu\Programs\Startup.
    '8=File system directory, the user's most recently used documents. Like: C:\Documents and Settings\username\Recent.
    '9=File system directory, Send To menu items. Like: C:\Documents and Settings\username\SendTo.
    '11=File system directory Start menu items. Like: C:\Documents and Settings\username\Start Menu.
    '15=Virtual folder the objects in the user's Recycle Bin.
    '16=File actual system directory used to store the file objects displayed the desktop. Not the desktop folder itself, A virtual folder. Like: C:\Documents and Settings\username\Desktop.
    '17=My Computer, virtual folder for the local computer: storage devices, printers, and Control Panel, may also contain mapped network drives.
    '18=Network Neighborhood, virtual folder representing the root of the network namespace hierarchy.
    '19=A file system folder the link objects that may exist in the My Network Places virtual folder. Not the same as the network folders.
    '20=Virtual folder installed fonts. Like: C:\WINNT\Fonts.
    '21=File system directory for document templates.
    '22=File system directory, the programs and folders the Start menu for users. Like: C:\Documents and Settings\All Users\Start Menu. Valid Win NT systems.
    '23=File system directory, the directories for the program groups the Start menu for users. Like: C:\Documents and Settings\All Users\Start Menu\Programs. Valid Win NT systems.
    '24=File system directory, the programs in the Startup folder for users. Like: C:\Documents and Settings\All Users\Start Menu\Programs\Startup. Valid Win NT systems.
    '25=File system directory, files and folders the desktop for all users. Like: C:\Documents and Settings\All Users\Desktop. Valid Win NT systems.
    '26=File system directory current application data.
    '27=File system directory, the link objects that may exist in the Printers virtual folder. Like: C:\Documents and Settings\username\PrintHood.
    '28= Ver. 5.0. File system directory the data repository for local (non-roaming) applications. Like: C:\Documents and Settings\username\Local Settings\Application Data.
    '29 = File system directory that corresponds to the user's nonlocalized Startup program group.
    '30=File system directory that corresponds to the nonlocalized Startup program group for all users. Valid MS Win NT systems.
    '31=File system directory for all users' favorite items. Valid Win NT systems.
    '32=File system directory for temporary Internet files. Like: C:\Documents and Settings\username\Temporary Internet Files.
    '33=File system directory for Internet cookies. Like: C:\Documents and Settings\username\Cookies.
    '34=File system directory for Internet history items.
    '35= Ver. 5.0. Application data for all users. Like: C:\Documents and Settings\All Users\Application Data.
    '36= Ver. 5.0. Win directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables. Like: C:\WINNT.
    '37= Ver. 5.0. System folder. Like: C:\WINNT\SYSTEM32.
    '38= Ver. 5.0. Program Files folder. Like: C:\Program Files.
    '39=My Pictures folder. Like: C:\Documents and Settings\username\My Documents\My Pictures.
    '40= Ver. 5.0. User's profile folder.


    If myPath <> "" Then MsgBox myPath, vbInformation + vbOKOnly, "Your Selected Path!"
    End Sub
    JSW: Try and try again: "The way of the Coder!"

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •