problem with basic scripts since version 5.1

I use basic scripts in our ERP system to open, create, modify etc. Calc documents.

This starts with the line
Set oServiceManager = CreateObject( “com.sun.star.ServiceManager” )
and worked fine with LibreOffice for years till version 5.1.
Now this line produces an error (Err.Number is -2147418113, F8000FFFF).
There are no changes in the ERP system nor in the script, everything still works fine on machines with LO 5.0. Only the machines with LO 5.1 have this problem.

I couldn’t find anything related in the release notes for version 5.1.
What has changed and what can I do to get my scripts working again with LibreOffice?

Bug report tdf 99643 exists for this problem.