Microsoft Excel

Ron de Bruin
Excel Automation

Microsoft MVP Program

Mac unique indentifier

This code can be useful if you want your code only to work on one machine. From what I read UUID used in the macro below was added in Leopard (Mac OS X 10.5). So if you have a Mac with a very old OSX the code below will not work.

Sub MachineUniqueIndentifierMac_1()
'Get the machine unique indentifier of a Mac
    Dim ScriptToRun As String
    Dim Answer As String

    ScriptToRun = _
    "set uuid to do shell script ""system_profiler SPHardwareDataType" & _
                " | awk '/Hardware UUID:/ {print $NF}'"""

    On Error Resume Next
    Answer = MacScript(ScriptToRun)
    On Error GoTo 0

    MsgBox Answer

    'Or add it to a cell in your worksheet so you can test
    'if your workbook is running on the correct machine
    'Sheets(1).Range("A1").Value = Answer

End Sub