The error you're encountering, Runtime error -2147221020 (800401e4) Automation error Invalid Syntax, typically indicates that the GetObject function is not able to retrieve the active SAP GUI
- Check SAP GUI Scripting is Enabled
- Ensure SAP Logon is Running as Administrator
- Use CreateObject Instead of GetObject
Set SapGuiAuto = CreateObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
MsgBox "SAP GUI could not be started."
Exit Sub
End If
- Check if SAP GUI is Running
- Verify 64-bit vs 32-bit
- Reinstall SAP GUI