'********************************************************************************************************** ' Name: createUUID ' Author: mielk | 2014-12-11 ' ' Comment: Function returns the path to the Desktop folder. ' ' Returns: ' String The full access path to the Desktop folder. ' ' ' Exceptions: ' CreatingObjectException Thrown if it was impossible to create an instance of Scriptlet.typeLib ' object. ' ' --- Changes log ----------------------------------------------------------------------------------------- ' 2014-12-11 mielk Function created. '********************************************************************************************************** Public Function createUUID() As String Const METHOD_NAME As String = "createUUID" '------------------------------------------------------------------------------------------------------ Const LIBRARY_NAME As String = "Scriptlet.TypeLib" '------------------------------------------------------------------------------------------------------ Dim typeLib As Object '------------------------------------------------------------------------------------------------------ 'Create a new instance of Scriptlet.TypeLib object --------------------------------------------------| On Error GoTo CreatingObjectException '| Set typeLib = VBA.CreateObject(LIBRARY_NAME) '| On Error GoTo 0 '| '----------------------------------------------------------------------------------------------------| 'If shell object has been properly created, use it to obtain Desktop folder path. -------------------| If Not typeLib Is Nothing Then '| createUUID = VBA.Mid$(typeLib.GUID, 2, 36) '| End If '| '----------------------------------------------------------------------------------------------------| '========================================================================================================== ExitPoint: Set typeLib = Nothing Exit Function '---------------------------------------------------------------------------------------------------------- CreatingObjectException: 'Error handler for the case if it was impossible to create an instance of Scriptlet.TypeLib object. GoTo ExitPoint End Function