Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Accessing local workstation's TEMP directory

Frederick:

Environ("Temp")

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

--
Dick 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default 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.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default 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

wrote in message
oups.com...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
file not found ...\local~\temp\vb514.tmp nathan Excel Discussion (Misc queries) 7 June 22nd 07 08:45 PM
Accessing Remote MDB Database from Local Computer [email protected] Excel Programming 1 February 9th 06 07:11 PM
shared workbook, local temp-file and network traffic petri Excel Discussion (Misc queries) 0 September 12th 05 10:51 PM
What Are And Can I Delete .EMF Files in WINNT/Temp Directory ? Donna[_7_] Excel Programming 2 February 15th 05 12:24 PM
How does Excel determine the TEMP directory? Miso Excel Programming 3 July 31st 03 02:19 PM


All times are GMT +1. The time now is 12:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"