How does Excel determine the TEMP directory?

M

Miso

Hello,

I would like to put Excel file into such a directory
in which I will be sure that has security settings ReadWrite.

If I know, on the arbitrary computer,
that Excel is working OK,
it means that Excel's TEMP directory has
under logged user security settings = ReadWrite.

If I set "C:\Documents and Settings\******\Local Settings\Temp"
directory to ReadOnly,
the Excel will not work.

The C function GetTempPath returns
the above directory, may The Excel using this C function?

Do anybody know which way the Excel determine
where the TEMP directory is?

Thanks

Miso
 
T

Tushar Mehta

ENVIRON("TEMP") or ENVIRON("TMP") should give you that information.

Also, with a reference to the Windows Scripting Host, the
GetSpecialFolder method of the FileSystemObject object will give you
what you want.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
O

Orlando Magalhães Filho

Hi Miso,

For me, until now this API always return Excel temp folder:

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

Function TempFolder() As String
'Get Temp Folder
Dim fctRet As Long
TempFolder = String$(255, 0)
fctRet = GetTempPath(255, TempFolder)
If fctRet <> 0 Then
TempFolder = Left(TempFolder, fctRet)
If Right(TempFolder, 1) = "\" Then TempFolder = Left(TempFolder,
Len(TempFolder) - 1)
Else
TempFolder = ""
End If
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top