+ Reply to Thread
Results 1 to 7 of 7

Accessing local workstation's TEMP directory

  1. #1
    Frederick Chow
    Guest

    Accessing local workstation's TEMP directory

    Hi all,

    Is there any way to access a local workstation's TEMP directory? Maybe it
    needs a Windows API, but I don't know how to do it. Thanks for your
    assistance.

    Frederick Chow
    Hong Kong.



  2. #2

    Re: Accessing local workstation's TEMP directory

    Hi
    (Not Tested)

    ChDrive "C:"
    ChDir ("C:\Temp")
    Do Events

    Will change to the C:\Temp folder. Save and so on will be to this
    folder. You might want to put this into an "On Error Return Next"
    incase there is no C:\Temp

    on error return next
    Err.Clear
    ChDrive "C:"
    ChDir ("C:\Temp")
    Do Events
    If err.number<>0 then
    msgbox "There is no C:\temp folder!"
    end if
    on error goto 0

    regards
    Paul


  3. #3
    Andrew Taylor
    Guest

    Re: Accessing local workstation's TEMP directory

    This method gets the user's temp directory (tested under Win XP):

    Option Explicit

    Declare Function GetTempPath Lib "kernel32" _
    Alias "GetTempPathA" _
    (ByVal nBufferLength As Long, _
    ByVal lpBuffer As String) As Long

    Sub GetTempDir()
    Dim lpBuffer As String, nBufferLength As Long, lResult As Long
    lpBuffer = Space(255)
    nBufferLength = 255
    lResult = GetTempPath(nBufferLength, lpBuffer)
    If InStr(lpBuffer, Chr(0)) > 0 Then ' trim trailing null character
    lpBuffer = Left(lpBuffer, InStr(lpBuffer, Chr(0)) - 1)
    End If
    MsgBox " Temp dir is [" & lpBuffer & "]"

    End Sub


    hth
    Andrew


    Frederick Chow wrote:
    > Hi all,
    >
    > Is there any way to access a local workstation's TEMP directory? Maybe it
    > needs a Windows API, but I don't know how to do it. Thanks for your
    > assistance.
    >
    > Frederick Chow
    > Hong Kong.



  4. #4
    Dick Kusleika
    Guest

    Re: Accessing local workstation's TEMP directory

    Frederick:

    Environ("Temp")

    will return a string that is the path to the windows temp directory.

    --
    **** Kusleika
    MS MVP - Excel
    www.dailydoseofexcel.com

    Frederick Chow wrote:
    > Hi all,
    >
    > Is there any way to access a local workstation's TEMP directory?
    > Maybe it needs a Windows API, but I don't know how to do it. Thanks
    > for your assistance.
    >
    > Frederick Chow
    > Hong Kong.




  5. #5
    Frederick Chow
    Guest

    Re: Accessing local workstation's TEMP directory

    Thanks for your quick response, but are there some Windows API that return
    the Temp directory of a local workstation? Your approach only checks if the
    temp directory is "C:\TEMP".

    Frederick Chow

    <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    > (Not Tested)
    >
    > ChDrive "C:"
    > ChDir ("C:\Temp")
    > Do Events
    >
    > Will change to the C:\Temp folder. Save and so on will be to this
    > folder. You might want to put this into an "On Error Return Next"
    > incase there is no C:\Temp
    >
    > on error return next
    > Err.Clear
    > ChDrive "C:"
    > ChDir ("C:\Temp")
    > Do Events
    > If err.number<>0 then
    > msgbox "There is no C:\temp folder!"
    > end if
    > on error goto 0
    >
    > regards
    > Paul
    >




  6. #6
    K Dales
    Guest

    RE: Accessing local workstation's TEMP directory

    Try Environ(Temp)
    --
    - K Dales


    "Frederick Chow" wrote:

    > Hi all,
    >
    > Is there any way to access a local workstation's TEMP directory? Maybe it
    > needs a Windows API, but I don't know how to do it. Thanks for your
    > assistance.
    >
    > Frederick Chow
    > Hong Kong.
    >
    >
    >


  7. #7
    Frederick Chow
    Guest

    Thanks to all of your suggestions (No Content)


    "Frederick Chow" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all,
    >
    > Is there any way to access a local workstation's TEMP directory? Maybe it
    > needs a Windows API, but I don't know how to do it. Thanks for your
    > assistance.
    >
    > Frederick Chow
    > Hong Kong.
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1