Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Accessing local workstation's TEMP directory

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frederick Chow - 20 Mar 2006 17:41 GMT
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.
paul.robinson@it-tallaght.ie - 20 Mar 2006 17:53 GMT
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
Frederick Chow - 20 Mar 2006 18:04 GMT
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

> Hi
> (Not Tested)
[quoted text clipped - 19 lines]
> regards
> Paul
Dick Kusleika - 20 Mar 2006 18:02 GMT
Frederick:

Environ("Temp")

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

Signature

Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com

> Hi all,
>
[quoted text clipped - 4 lines]
> Frederick Chow
> Hong Kong.
Andrew Taylor - 20 Mar 2006 18:02 GMT
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

> Hi all,
>
[quoted text clipped - 4 lines]
> Frederick Chow
> Hong Kong.
K Dales - 20 Mar 2006 18:04 GMT
Try Environ(Temp)
Signature

- K Dales

> Hi all,
>
[quoted text clipped - 4 lines]
> Frederick Chow
> Hong Kong.
Frederick Chow - 20 Mar 2006 18:40 GMT
> Hi all,
>
[quoted text clipped - 4 lines]
> Frederick Chow
> Hong Kong.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.