Signature (Visual Basic / VBA)
Public Function GetTempFileName( _
Optional ByVal vSuggestPath As Variant _
, Optional ByVal vPrefix As Variant _
) As String
Code Example
? GetTempFileName(Null, Null)
C:\TEMP\F185.TMP
? GetTempFileName("C:\WINDOWS", Null)
C:\WINDOWS\34.TMP
? GetTempFileName("C:\WINDOWS", "ABCDEF")
C:\WINDOWS\ABCC1.TMP
? GetTempFileName(Null, "ABCDEF")
C:\TEMP\ABCF380.TMP
Parameters
| Parameter | Description |
|---|---|
| vSuggestPath | A string that suggests the directory in where the temporary file should be created. vSuggestPath defaults to the Windows temporary directory (usually "C:\TEMP" or "C:\TEMP\WINDOWS") if it is missing or Null or cannot be fixed-up to a string. See the Microsoft Windows API documentation for the GetTempFileName function for more details about the suggested path argument. |
| vPrefix | A string that suggests the prefix of the temporary file name. All or part or none of the prefix may be used by the GetTempFileName (Microsoft Windows API) function. See the Microsoft Windows API documentation for the GetTempFileName function for more details about the prefix argument. |
Notes & Version History
| Note | You will likely get different results when you run these examples because the temporary file names are based partially upon the current time. |
| Note | These examples will create empty files with the specified names, so you may want to consider following each example with the Kill command to get rid of the file. |
| v1.3 Change | Removed 16-bit support from this function. |