[AccessD] Windows Temporary Directory

Stuart McLachlan stuart at lexacorp.com.pg
Mon Aug 15 16:16:30 CDT 2011


I put this in a Public module:

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

Public Function TempDir() As String
Dim strPath As String
 strPath = Space(MAX_PATH)
 GetTempPath Len(strPath), strPath
  TempDir = Left(strPath, InStr(1, strPath, vbNullChar) - 1)
End Function
</code>

and then use it like this:

<code>
'build full path/file name and delimit with qiuotes to
'allow for spaces in path of file

strQ = chr$(34)
strFile = "myfile.txt"
strFile = strQ & Tempdir()  & strFile & strQ

'Now open file from a Shell
strShell = "Notepad.exe " &  & strFile
retval = Shell(strShell)
</code>

-- 
Stuart
On 15 Aug 2011 at 8:07, Dale Kalsow wrote:

> Good Morning,
>  
> I am trying to write a file into the windows temporary directory but
> am having issues referencing it.  Could someone tell me the propery
> way to reference the temp direcory when using the RetVal = Shell()
> command.   Thanks!   Dale -- AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd Website:
> http://www.databaseadvisors.com
> 







More information about the AccessD mailing list