View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Save files to generalized location?

Yes, you would do it that way or you could just use the environ function
from VBA

? environ("tmp")
C:\DOCUME~1\OgilvyTW\LOCALS~1\Temp

so
tmpPath = environ("tmp")

? environ("temp")
C:\DOCUME~1\OgilvyTW\LOCALS~1\Temp

or
tmpPath = environ("temp")

comparing the API results to the above:

? GetTempPath()
C:\DOCUME~1\OgilvyTW\LOCALS~1\Temp\

Line with "?" were entered in the immediate window for execution. The next
line shows the results of that executed line.

--
Regards,
Tom Ogilvy


"rach85" wrote in
message ...

hi Robert!

Nah, i'm pretty slow here as i know nuts about macro.

So thanks for your patience!

so the code will be placed in the module like this:

Option Explicit

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

Function GetTempPath() As String
Dim lpBuffer As String
Dim nBufferLength As Long
Dim Ret As Long

nBufferLength = 255
lpBuffer = Space$(nBufferLength)
Ret = GetTempPathA(nBufferLength, lpBuffer)
GetTempPath = Left$(lpBuffer, Ret)

End Function


--
rach85
------------------------------------------------------------------------
rach85's Profile:

http://www.excelforum.com/member.php...o&userid=16557
View this thread: http://www.excelforum.com/showthread...hreadid=510514