' Lesson 1: checks whether SAP GUI scripting is available. Run with SAP Logon open and logged in.
On Error Resume Next
Set SapGuiAuto = GetObject("SAPGUI")
If Err.Number <> 0 Then
  MsgBox "SAP GUI is not running or scripting is disabled on this PC."
Else
  Set app = SapGuiAuto.GetScriptingEngine
  MsgBox "Scripting engine OK. Open connections: " & app.Children.Count
End If
